Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

Using arbitrary types for attribute values

Automated tasks on server

Using arbitrary types for attribute values

Postby AndyF1 » 17 Jul 2013 18:18

Hi all,
I'm relatively new to Gephi. I just tried to store some values in a vertex using

getNodeData().getAttributes().setValue(0, status);

status is of any type. but once i access it using


i always get my value in its string representation. In the javadoc there is no hint indicating that. How do I have to use the attributes to keep my original values? Or is there another way to guickly store and access vertex status of any type?

Posts: 4
Joined: 21 Apr 2013 21:41

Re: Using arbitrary types for attribute values

Postby seinecle » 22 Jul 2013 15:38

Can't you cast the attribute as the type you need? Like:

(Integer) getNodeData().getAttributes().getValue(0);

If the type of 0 can change, I am sure it is possible to dynamically cast it to whatever was its original type (not an expert in Java to know how this would be done though).

Hope this helps,


Gephi tutorials and personalized trainings: http://www.clementlevallois.net/training.html
Join the Gephi Facebook group for help and support: https://www.facebook.com/groups/gephi/
User avatar
Gephi Community Support
Posts: 527
Joined: 08 Feb 2010 17:55
Location: Lyon, France

Re: Using arbitrary types for attribute values

Postby AndyF1 » 22 Jul 2013 17:43

in the meantime I found another solution to the problem of assigning and accessing arbitrary node and edge status objects in O(1).
But if someone is interested:
the problem was, that even though the return type of getValue() is Object, the (runtime) type was always String, that is, the value I passed was always stored in its string representation. I checked the stack trace of a toString call and saw, that there are some typechecks and it tries to parse the string representation if the type is unknown. So the attribute system cannot be used for that because, as I know now, it has another purpose.
Posts: 4
Joined: 21 Apr 2013 21:41

Re: Using arbitrary types for attribute values

Postby eduramiba » 24 Jul 2013 20:16

Your value is converted to String because the Id column of nodes (index 0) has String type.
You could add a column of the desired type for your purposes. Check this example to get started http://wiki.gephi.org/index.php/Toolkit ... attributes

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
Gephi Code Manager
Posts: 579
Joined: 22 Mar 2010 16:30
Location: Zaragoza, Spain

Return to Toolkit

Who is online

Users browsing this forum: Bing [Bot] and 0 guests