[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 •Problem with types in jython console
Page 1 of 1

Problem with types in jython console

Posted: 04 Jan 2013 15:50
by stablum
Hi,

I am trying to run a graph metric algorithm in the jython console. Unfortunately I cannot call the method 'execute' in a GraphDistance object.

This is the class of statistics object I need to use:

Code: Select all

>>> type(gd)
<type 'org.gephi.statistics.plugin.GraphDistance'>
The type of the graph class is this:

Code: Select all

>>> type(gu)
<type 'org.gephi.graph.dhns.graph.HierarchicalUndirectedGraphImpl'>
That is actually a subclass of HierarchicalGraph:

Code: Select all

>>> gu.class.__bases__[0].__bases__[0]
<type 'org.gephi.graph.api.HierarchicalGraph'>
I also have the 'attributes' object as requested:

Code: Select all

>>> type(ga)
<type 'org.gephi.data.attributes.AttributeRowImpl'>
But the execute states that the required type is not correct:

Code: Select all

>>> gd.execute(gu,ga)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: execute(): 1st arg can't be coerced to org.gephi.graph.api.HierarchicalGraph, org.gephi.graph.api.GraphModel
This does not make much sense for me since the class of the graph object I am using is derived from the class that is required.

Any ideas?

Re: Problem with types in jython console

Posted: 04 Jan 2013 23:13
by eduramiba
Hi,
The first argument actually looks fine, but the second argument should be of type org.gephi.data.attributes.api.AttributeModel instead of org.gephi.data.attributes.AttributeRowImpl.

Eduardo

Re: Problem with types in jython console

Posted: 06 Jan 2013 15:32
by stablum
Thanks! Do you know how to get the AttributeModel? I am trying to experiment with many methods of the 'g' global variable, but i am not finding anything useful.
cheers,
Francesco

Re: Problem with types in jython console

Posted: 07 Jan 2013 14:35
by eduramiba
Hi,
Try the following code:

Code: Select all

import org.openide.util.Lookup;
import org.gephi.data.attributes.api.AttributeController;
org.openide.util.Lookup.getDefault().lookup(org.gephi.data.attributes.api.AttributeController).getModel();
You can obtain many different controllers such as GraphController, AttributeController or DynamicController in Gephi through the Lookup mechanism.
Eduardo