0

So I'm building a graph with networkx and I want the size of the nodes to be a certain size according to a certain node attribute. I am trying to add this style setting in the graphml file so that Cytoscape can recognize it. That way you just have to open the file with Cytoscape and you will have that style there without doing anything. Is this possible? I read this question here Transfer layout from networkx to cytoscape but I couldn't get it to work. When I set the node attributes as "h" and "w" Cytoscape didn't recognize them as style setting just as normal attributes.

For example:
import networkx as nx

G = nx.Graph()  
G.add_edge(0,1)  
G.add_edge(2,1)    
importancedic =  {0: {'importance' : 1.6}, 1:{'importance': 4.2}, 2:{'importance':5.4}}    
nx.set_node_attributes(G, importancedic)  

I have this importance dictionary, I want the node to have different sizes according to the values ​​of this dictionary (the smaller the value, the bigger the node).
How can I add this style setting as it appears in graphml and then Cytoscape when imported there?

Beatriz
  • 1
  • 1
  • share what have you done so far, with some reproducible graph smaple. – micro5 Jun 03 '22 at 04:34
  • Sorry! Just added a small example there! – Beatriz Jun 06 '22 at 13:06
  • How are you transferring the graph to Cytoscape? Are you exporting it as a GML file? If so, can you give us an example of the GML file you are generating? My general recommendation, though, would be to use py4cytoscape and transfer the graph directly. That will also give you complete control over the Cytoscape style mechanism, so that you can set a style linking "importance" to size. – Scooter Morris Jun 09 '22 at 14:58

0 Answers0