Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gephi scripting console not showing nodes

Am I missing something or is this a strange bug in Gephi scripting console ?

the console shows edges but no nodes

for example

>>> len(g.edges)
4314
>>> len(g.nodes)
1

>>> g.edges
set([e8926, e8794, e7024 ......])
>>> g.nodes
set([None])

You can replicate the error using the dataset Power Grid.gml provided with Gephi. I tested this on several datasets from here for example and got the same error.

Am I doing something wrong ?

like image 710
user1043144 Avatar asked May 02 '26 08:05

user1043144


2 Answers

there is a plugin named "Data Table", when you install it, you can see the structure of your dataset. i had a problem exactly like that, and i understood the node id, is a string not a number. if you want to see the difference in scripting Plugins execute g.nodes() command in Console Scripting Plugin, you can see (from "Data Table" Plugin that) the id of new created node is a number not a string. and when you execute g.nodes or len(g.nodes) in Gephi Console, you can see the new created node. I solve it in this way: i installed a Plugin named "Data Table", in can "Export Table", choose it, it tells you which columns you need to export you choose whatever you want but not the Id, then choose a separator and press Ok it will save it. make a new project, open "Data Table" plugins then click "Import SpreadSheet" from here you can insert your dataset with a new column named "Id" that gephi on its own add it to your DataSet

like image 72
Mohsen Avatar answered May 03 '26 20:05

Mohsen


Now two years after the original question the bug is still there where in the Jython console of Gephi where:

>>> g.nodes
set([None])

However, I found a workaround to directly manipulate the nodes through the scripting console like this:

>>> graph = g.getUnderlyingGraph()
>>> nodes = [node for node in graph.nodes]
>>> nodes
[n0, n1, n2, n3, n4, n5, n6, n7, ...

By doing this I was able to manipulate the node attributes like this:

>>> node = nodes[0]
>>> attr = node.attributes
>>> value = attr.getValue('attribute_name')
>>> new_value = do_something(value)
>>> attr.setValue('attribute_name', new_value)
like image 33
RickardSjogren Avatar answered May 03 '26 22:05

RickardSjogren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!