ValueError: Can't clean for JSON for networkx nodes that are objects.
See original GitHub issueExecute the following in a jupyter lab notebook and you’ll get ‘ValueError: Can’t clean for JSON’. I believe this should work, and is a bug. It works fine if I use nx.draw(G) instead of ipycytoscape.
import ipycytoscape
import networkx as nx
class Node:
def __init__(self, name):
self.name = name
n1 = Node("node 1")
n2 = Node("node 2")
G = nx.Graph()
G.add_node(n1)
G.add_node(n2)
G.add_edge(n1, n2)
undirected = ipycytoscape.CytoscapeWidget()
undirected.graph.add_graph_from_networkx(G)
undirected
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Jupyter Lab ValueError: Can't clean for JSON - Plotly Python
Really new to the Jupyter/Pandas/Plotly ecosystem. Successfully reading in dataframes and calculating some new columns with success.
Read more >NetworkX Reference
NetworkX is a Python language software package for the creation, manipulation, and study of the structure, dynamics,.
Read more >Method to save networkx graph to json graph? - Stack Overflow
Show activity on this post. Seems like there should be a method in networkx to export the json graph format, but I don't...
Read more >NetworkX Reference - Read the Docs
NetworkX is a Python language software package for the creation, manipulation, and study of the structure, dynamics,.
Read more >OSMnx: Python for Street Networks - Geoff Boeing
OpenStreetMap nodes can be weird: they include intersections, ... how could I load back the saved shapefile into a networkx graph object.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any specific use case for having custom classes? (unless the idea here is to mirror exactly nx.draw). The
str()
argument will make it work with ipycytoscape but we will essentially lose all the information of the object. (which should be okay if we want to make ipycytoscape compatible with hashable node objects).If the idea here is to pass information from the Node custom object to the ipycytoscape graph object then we can do something like
and we can access the newly created custom nodes by something like
gotcha, sorry, I missed the call to str() in your’s the first time i looked at it.