The NetworkX workbench

Pyodide, preloaded nx and plt, files, and privacy.

NetworkX graphs are Python objects. Print version and a two-edge path.

Goal

Create Nairobi—Nakuru—Kisumu and print nodes.

import networkx as nx
print(nx.__version__)
G = nx.Graph()
G.add_edge('Nairobi', 'Nakuru')
print(list(G.nodes()))
import networkx as nx
G = nx.path_graph(['Nairobi', 'Nakuru', 'Kisumu'])
print(list(G.edges()))