isn't it too complicated code for starting the Toolkit?

User's perspective on software quality
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
xlinee
Posts:2
Joined:08 Dec 2012 23:49
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
isn't it too complicated code for starting the Toolkit?

Post by xlinee » 10 Dec 2012 04:31

Hi,

I'm just newbie to Gephi and I like it. When I used the toolkit is seems to me the code is too complicated (compared to other libraries I've used in the past 10 years).

I believe wrapper classes will make things much easier to the users (and third party developers).

For instance this is the toolkit code for getting different measures:

Code: Select all

    ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
    pc.newProject();
    Workspace workspace=pc.getCurrentWorkspace();
   ImportController importController=Lookup.getDefault().lookup(ImportController.class);
   
   try{
       
       File file=new File("example.csv");
       container=importController.importFile(file);
       container.getLoader().setEdgeDefault(EdgeDefault.UNDIRECTED);
       container.setAllowAutoNode(false);
       
       
   }catch(Exception ex)
   {
       ex.printStackTrace();
       return;
   }
  
   importController.process(container,new DefaultProcessor(),workspace);
   GraphModel graphModel=Lookup.getDefault().lookup(GraphController.class).getModel();
   AttributeModel attributeModel=Lookup.getDefault().lookup(AttributeController.class).getModel();
   Graph graph = graphModel.getGraph();
   
   GraphDistance distance=new GraphDistance();
   distance.setDirected(false);
   distance.execute(graphModel, attributeModel);
   AttributeColumn col=attributeModel.getNodeTable().getColumn(GraphDistance.BETWEENNESS);
   AttributeColumn col2=attributeModel.getNodeTable().getColumn(GraphDistance.CLOSENESS);
   
   for(Node n:graph.getNodes())
   {
       
   System.out.println(n.getNodeData().getId()+" betweenness="+
           n.getNodeData().getAttributes().getValue(col.getIndex())+
           " closeness="+n.getNodeData().getAttributes().getValue(col2.getIndex())+
           " degree="+graph.getDegree(n));
   }
   
   
isn't it too much? too detailed?

Here's an example of how things can be with wrapper classes.

Code: Select all

  Project project=new Project(PARAMETER.IF.NEEDED);
    Container container=new Container(new File("example.csv"));
    Measurement centrality=container.getCentrality();
    Measurement betweenness=container.getBetweenness();
    Measurement closeness=container.getCloseness();
    
    for(Entry entry:centrality)
        System.out.println(entry.getName()+ "centrality="+entry.getValue());

For exporting files I actually doing it myself since i'm its too complicated in the toolkit.

Again, its just a suggestion no more no less.
Thanks

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: isn't it too complicated code for starting the Toolkit?

Post by seinecle » 10 Dec 2012 14:22

Hi,

As an entry-level Java coder I must say I appreciate this remark very much. Yes, I find the language of the API complicated as compared to other APIs. As a result I don't use it...

I understand that it might be just a useless suggestion, because there are probably tones of good reasons why things are the way they are and can't be changed. But since an API is there to be used, feedback on the API usability can be heard! Ok, done!

User avatar
eduramiba
Gephi Code Manager
Posts:1064
Joined:22 Mar 2010 15:30
Location:Madrid, Spain
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: isn't it too complicated code for starting the Toolkit?

Post by eduramiba » 10 Dec 2012 23:47

Hi,
The Gephi APIs were initially designed for building the desktop application, and later released as a library with the toolkit.

But it's true that some wrapper classes that used the full API could be written just to simplify the usage of it in the toolkit.

Eduardo

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: isn't it too complicated code for starting the Toolkit?

Post by seinecle » 18 Dec 2012 16:41

Maybe an idea for a Summer of Code project?

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable