Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

Modularity raises null pointer exception

Automated tasks on server

Modularity raises null pointer exception

Postby cdexter » 21 Apr 2012 02:25

Hi,
I copied from the demo some code to run the modularity algorithm and get a null pointer exception.

Here is my code:
Code: Select all
       ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
      pc.newProject();
      Workspace workspace = pc.getCurrentWorkspace();
      
      AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
      PartitionController partitionController = Lookup.getDefault().lookup(PartitionController.class);
      
      // load the graph from the gexf file
       //Import first file
       ImportController importController = Lookup.getDefault().lookup(ImportController.class);
       Container container;
        File file = new File(gexfInFilePath);
        container = importController.importFile(file);
        container.setAllowAutoNode(false);  //Don’t create missing nodes
   
       importController.process(container, new DefaultProcessor(), workspace);
      
       GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
       UndirectedGraph graph = graphModel.getUndirectedGraph();
      
       //Run modularity algorithm - community detection
       Modularity modularity = new Modularity();
       modularity.execute(graphModel, attributeModel);


gexfInFilePath is the path to a gexf file which opens fine from the Gephi ui. Actually, I can run modularity on that graph from the UI. Only the code above raises an exception. Here is the exception:

Code: Select all
Exception in thread "main" java.lang.NullPointerException
   at org.gephi.statistics.plugin.Modularity$CommunityStructure.removeNodeFrom(Modularity.java:259)
   at org.gephi.statistics.plugin.Modularity$CommunityStructure.moveNodeTo(Modularity.java:292)
   at org.gephi.statistics.plugin.Modularity$CommunityStructure.access$300(Modularity.java:122)
   at org.gephi.statistics.plugin.Modularity.execute(Modularity.java:436)
   at org.gephi.statistics.plugin.Modularity.execute(Modularity.java:396)
   at com.ebay.erl.formatter.GexfGenerator.extractCommunites(GexfGenerator.java:203)
   at com.ebay.erl.formatter.GexfGenerator.main(GexfGenerator.java:331)


Any suggestion?
cdexter
 
Posts: 4
Joined: 13 Dec 2011 20:55

Re: Modularity raises null pointer exception

Postby eduramiba » 22 Apr 2012 15:23

Hi,
Did you check the option 'use weight' in the UI?
The problem may be this bug https://github.com/gephi/gephi/issues/577 and the toolkit will need to be rebuilt.

Can you try to set useWeight to false in your code and tell us if the problem persists?

Eduardo
Life... is like a grapefruit. It's orange and squishy, and has a few pips in it, and some folks have half a one for breakfast.
User avatar
eduramiba
Gephi Code Manager
 
Posts: 579
Joined: 22 Mar 2010 16:30
Location: Zaragoza, Spain

Re: Modularity raises null pointer exception

Postby cdexter » 23 Apr 2012 18:27

Good catch. When I set
Code: Select all
modularity.setUseWeight(false)
the code runs fine.
Many thanks. I'll be waiting for the new build of the toolkit.
Cheers.
cdexter
 
Posts: 4
Joined: 13 Dec 2011 20:55

Re: Modularity raises null pointer exception

Postby eduramiba » 23 Apr 2012 22:25

Great, thanks for the report.
I'll post something here when we upload a new toolkit version.

Eduardo
Life... is like a grapefruit. It's orange and squishy, and has a few pips in it, and some folks have half a one for breakfast.
User avatar
eduramiba
Gephi Code Manager
 
Posts: 579
Joined: 22 Mar 2010 16:30
Location: Zaragoza, Spain

Re: Modularity raises null pointer exception

Postby gamma2 » 22 May 2012 12:05

eduramiba wrote:Great, thanks for the report.
I'll post something here when we upload a new toolkit version.

Eduardo


The problem seems have been fixed in gephi, how long before a patch for the toolkit?

Giuseppe
gamma2
 
Posts: 16
Joined: 20 Sep 2011 10:20
Location: Bologna, Italy

Re: Modularity raises null pointer exception

Postby eduramiba » 06 Jun 2012 21:13

Hi,
I just uploaded a new toolkit version.
https://launchpad.net/gephi/toolkit/toolkit-0.8.6

Eduardo
Life... is like a grapefruit. It's orange and squishy, and has a few pips in it, and some folks have half a one for breakfast.
User avatar
eduramiba
Gephi Code Manager
 
Posts: 579
Joined: 22 Mar 2010 16:30
Location: Zaragoza, Spain


Return to Toolkit

Who is online

Users browsing this forum: No registered users and 0 guests