#!/usr/bin/env python # coding: utf-8 # # Test NetworkX methods # In[ ]: import ipycytoscape import ipywidgets as widgets import networkx as nx # In[ ]: cytoscapeobj = ipycytoscape.CytoscapeWidget() # In[ ]: 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.complete_graph(nx.complete_graph(5)) button.on_click(on_button_clicked) widgets.HBox([button, cytoscapeobj]) # In[ ]: # Manipulate a graph using NetworkX nx_graph = nx.complete_graph(7) # Using its algorithms nx.shortest_path(nx_graph, 1, 5) # In[ ]: # Create a new NX graph without using a button cytoscapeobj.complete_graph(nx_graph) # In[ ]: # Manipulate the NX graph using cytoscape cytoscapeobj.set_layout(name='grid', nodeSpacing=10, edgeLengthVal=10) # In[ ]: