NetworkX

Package: networkx · 20 nodes · Graph analysis and network science

Build graph analysis pipelines visually — create graphs, run algorithms, and inspect results on a canvas. NetworkX can run as a standalone project or be enabled as a composable library inside any framework's graph.

Node Reference

Node Type Inputs Outputs
Create Graph statement - Graph (nx.Graph)
Add Node statement Graph (nx.Graph), Node (any) -
Add Edge statement Graph (nx.Graph), From (any), To (any), Weight (float) -
Has Node expression Graph (nx.Graph), Node (any) Exists (bool)
Has Edge expression Graph (nx.Graph), From (any), To (any) Exists (bool)
Neighbors expression Graph (nx.Graph), Node (any) Neighbors (list)
Degree expression Graph (nx.Graph), Node (any) Degree (int)
Node Count expression Graph (nx.Graph) Count (int)
Complete Graph expression Nodes (int) Graph (nx.Graph)
Random Graph expression Nodes (int), Probability (float) Graph (nx.Graph)
Barabasi Albert expression Nodes (int), Edges/Node (int) Graph (nx.Graph)
Grid 2d expression Rows (int), Cols (int) Graph (nx.Graph)
Shortest Path expression Graph (nx.Graph), Source (any), Target (any) Path (list)
Shortest Path Length expression Graph (nx.Graph), Source (any), Target (any) Length (int)
Has Path expression Graph (nx.Graph), Source (any), Target (any) Connected (bool)
Degree Centrality expression Graph (nx.Graph) Centrality (dict<string, any>)
Betweenness Centrality expression Graph (nx.Graph) Centrality (dict<string, any>)
Pagerank expression Graph (nx.Graph) Ranks (dict<string, any>)
Connected Components expression Graph (nx.Graph) Components (list), Count (int)
Is Connected expression Graph (nx.Graph) Connected (bool)

Creating Graphs

Create Graph is a statement node. Use the dropdown to select the graph type:

Type Directed Parallel Edges Python
Graph No No nx.Graph()
DiGraph Yes No nx.DiGraph()
MultiGraph No Yes nx.MultiGraph()
MultiDiGraph Yes Yes nx.MultiDiGraph()

Add Node generates G.add_node(n). Add Edge generates G.add_edge(u, v) or G.add_edge(u, v, weight=w) when weight is connected.

Graph Generators

Generator nodes are expression nodes — no exec ports, they produce a graph value directly.

  • Complete Graph — Kn: nx.complete_graph(n)
  • Random Graph — Erdos-Renyi: nx.erdos_renyi_graph(n, p)
  • Barabasi-Albert — Scale-free via preferential attachment: nx.barabasi_albert_graph(n, m)
  • Grid 2D — Lattice: nx.grid_2d_graph(m, n)

Querying Graphs

All query nodes are expression nodes resolved when their output is needed.

  • Has Node / Has Edge — Boolean existence checks
  • Neighborslist(G.neighbors(n))
  • DegreeG.degree(n)
  • Node CountG.number_of_nodes()

Paths & Distances

  • Shortest Pathnx.shortest_path(G, source, target) (raises error if no path)
  • Shortest Path Lengthnx.shortest_path_length(G, source, target)
  • Has Pathnx.has_path(G, source, target) (use with Branch for safe path-finding)

Centrality Measures

All return a dict mapping node IDs to float scores.

  • Degree Centrality — Importance by connection count, normalized [0, 1]
  • Betweenness Centrality — How often a node is a bridge between others
  • PageRank — Recursive importance (works best on DiGraph)

Connected Components

  • Connected Components — Returns Components (list of sets) and Count
  • Is Connected — Boolean check for full connectivity

These work on undirected graphs. For directed graphs, Is Connected performs a weak connectivity check.