Search code examples
networkxipywidgetsipycytoscape

Plot a graph with ipycytoscape (and networkx)


Following the instructions of ipycitoscape I am not able to plot a graph using ipycitoscape.

according to: https://github.com/QuantStack/ipycytoscape/blob/master/examples/Test%20NetworkX%20methods.ipynb

this should work:

import networkx as nx
import ipycytoscape

G2 = nx.Graph()
G2.add_nodes_from([*'ABCDEF'])
G2.add_edges_from([('A','B'),('B','C'),('C','D'),('E','F')])

print(G2.nodes)
print(G2.edges)
cytoscapeobj = ipycytoscape.CytoscapeWidget()
cytoscapeobj.graph.add_graph_from_networkx(nx_graph)

G2 is a networkx graph example and it looks ok since print(G2) gives the networkx object back and G2.nodes and G2.edges can be printed.

The error:

ValueError: invalid literal for int() with base 10: 'A'

Why should a node be an integer? More general what to do if the starting data point if a pandas dataframe with a million rows edges those being strings like ProcessA-ProcessB, processC-processD etc

Also having a look to the examples it is to be noted that the list of nodes is composed of a dictionary data for every node. that data including an "id" per node and also "Atribute". The surprise here is that the networkx Graph should have all those properties.

thanks


Solution

  • This problem was fixed. See attachment.enter image description here

    Please let me know if it's still happening. Feel free to open an issue: https://github.com/QuantStack/ipycytoscape/