import ipycytoscape
import ipywidgets as widgets
import networkx as nx
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-1-2bf730a60419> in <module> 1 import ipycytoscape 2 import ipywidgets as widgets ----> 3 import networkx as nx ModuleNotFoundError: No module named 'networkx'
cytoscapeobj = ipycytoscape.CytoscapeWidget()
button = widgets.Button(description="nx graph")
output = widgets.Output()
# Generates a NX graph every time you click the button
def on_button_clicked(b):
with output:
cytoscapeobj.graph.add_graph_from_networkx(nx.complete_graph(5))
button.on_click(on_button_clicked)
widgets.HBox([button, cytoscapeobj])
HBox(children=(Button(description='nx graph', style=ButtonStyle()), CytoscapeWidget(cytoscape_layout={'name': …
# Manipulate a graph using NetworkX
nx_graph = nx.complete_graph(7)
# Using its algorithms
nx.shortest_path(nx_graph, 1, 5)
# Create a new NX graph without using a button
cytoscapeobj.graph.add_graph_from_networkx(nx_graph)
# Manipulate the NX graph using cytoscape
cytoscapeobj.set_layout(name='grid', nodeSpacing=10, edgeLengthVal=10)
cytoscapeobj.graph.add_graph_from_networkx(nx.complete_graph(5))
cytoscapeobj
cytoscapeobj.graph