python - Transfer layout from networkx to cytoscape -


i want use networkx generate layout graph. possible transfer layout cytoscape , draw there? tried write graph as

import networkx nx g = nx.graph() g.add_edge(0,1,weight=.1) g.add_edge(2,1,weight=.2) nx.write_gml(g,'g.gml') nx.write_graphml(g,'g.xml') 

but neither of these read in cytoscape. not sure how transfer graph in format can include positions.

your g.xml graphml file looks good, , loads cytoscape me (i'm on mac). have installed graphmlreader plugin?

if not, download , drop plugins folder, restart cytoscape , try loading g.xml network again.

update here code add graphics look-and-feel , positioning networkx graph. bit verbose, , may able omit of attributes depending on needs:

import networkx nx  g = nx.graph() g.add_edge(0, 1, weight=0.1, label='edge', graphics={     'width': 1.0, 'fill': '"#0000ff"', 'type': '"line"', 'line': [],     'source_arrow': 0, 'target_arrow': 0}) nx.set_node_attributes(g, 'graphics', {     0: {'x': -85.0, 'y': -97.0, 'w': 20.0, 'h': 20.0,         'type': '"ellipse"', 'fill': '"#889999"', 'outline': '"#666666"',         'outline_width': 1.0},     1: {'x': -16.0, 'y': -1.0, 'w': 40.0, 'h': 40.0,         'type': '"ellipse"', 'fill': '"#ff9999"', 'outline': '"#666666"',         'outline_width': 1.0}     }) nx.set_node_attributes(g, 'label', {0: "0", 1: "1"}) nx.write_gml(g, 'network.gml') 

result:

enter image description here


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -