[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
Gephi forums •[SOLVED] Adding extra variables to NodeData, can it be done?
Page 1 of 1

[SOLVED] Adding extra variables to NodeData, can it be done?

Posted: 07 Nov 2010 05:21
by Mountaineer
Hello!

I am trying to add a extra variable to the NodeData class, along with appropriate get/set functions. However Gephi crashes the moment such a function is called. Netbeans does not indicate any errors with recognizing the method, and the following code snippet inside DHNSEventBridge compiles fine.

Code: Select all

    public void simulate() // called when selected from the right click menu
    {
        this.graph = graphController.getModel().getHierarchicalGraphVisible();
        ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
        for (ModelImpl metaModelImpl : selectedNodeModels)
        {
            NodeData nodeData = (NodeData) metaModelImpl.getObj();
            nodeData.setColor(0, 1, 0);
            nodeData.setDiseased(true);  // Causes Gephi to crash
        }
   }
What would cause Gephi to crash from this? Does it have something to do with the nature of metaModelImpl?

Thank you

Re: Adding extra variables to NodeData, can it be done?

Posted: 07 Nov 2010 10:46
by mbastian
This code can't compile fine in Java, as the 'setDiseased' method is not defined. Check your Netbeans install, as this shouldn't compile.

You can easily add data to nodes by using attributes:

Code: Select all

nodedata.getAttributes.setValue("diseased", true )
Don't forget to first define the new column:

Code: Select all

AttributeModel attModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
attModel.getNodeTable().addColumn("diseased", AttributeType.BOOLEAN);

Re: Adding extra variables to NodeData, can it be done?

Posted: 07 Nov 2010 16:26
by Mountaineer
Thank you so much! You devs are great!

Now where would be the best place to put these addColumns in? If they get called more than once then Gephi throws an error.

Code: Select all

AttributeModel attModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
attModel.getNodeTable().addColumn("diseased", AttributeType.BOOLEAN);
My last question is this, say I created my own attribute, like what's happening here, only with doubles. Would it appear on the "Choose a rank parameter" dropdown menu? Or are the list of available rankings set in stone during import?

Re: Adding extra variables to NodeData, can it be done?

Posted: 08 Nov 2010 16:20
by mbastian
Now where would be the best place to put these addColumns in
You have to call this once only, you can also use hasColumn() method and for instanc eonly add the column if it doesn't exist already.
My last question is this, say I created my own attribute, like what's happening here, only with doubles. Would it appear on the "Choose a rank parameter" dropdown menu? Or are the list of available rankings set in stone during import?
All numerical attributes (float, double, integer, ...) are automatically available through ranking, you don't have to do anything. Once added as a column, Ranking can use it.

Re: Adding extra variables to NodeData, can it be done?

Posted: 22 Mar 2011 20:39
by galwarion
Is it possible to do ranking dynammicaly? I have already tried it... But for me its working only when I run ranking I some time pieces edged in the time line... But maybe I'm doing something bad?

Re: Adding extra variables to NodeData, can it be done?

Posted: 23 Mar 2011 16:18
by mbastian
Ranking doesn't refresh dynamically yet when you manipulate the timelime. However, it will use the proper time range to extract current values in the range when you click on 'Apply'