0

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

JFerro
  • 3,203
  • 7
  • 35
  • 88
  • 1
    I recently had a problem generating a Sankey diagram giving me type error. The reason turned out to be that my graph had an orphan node ie. a node that didn't connect to anything else. The software to generate the SANKEY couldn't handle that circumstance and threw a type error because it assigned the expected a connection a value of NaN. Just saying, a weird type error might be related to something totally different than you expect. – MikeB2019x Jun 22 '20 at 14:49

2 Answers2

3

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/

  • 1
    Thanks for your contribution. Let me mention (on the side) that people here at StackOverflow prefer text of pictures of text, but that only slightly tarnishes your post. ;-) – Yunnosch Aug 25 '20 at 09:51
0

I'm just playing around with ipycytoscape myself, so I could be way off-base, but, shouldn't the line be:

cytoscapeobj.graph.add_graph_from_networkx(G2) # your graph name goes here

Trying to generate a cytoscape object built on a graph that doesn't exist might trigger a ValueError because it can't find any nodes.