iduedu.urban_graph2nx_graph

iduedu.urban_graph2nx_graph(urban_graph)[source]

Convert an UrbanGraph to a NetworkX graph.

NetworkX is not required for normal IduEdu workflows, but this conversion is useful at integration boundaries with tools that consume NetworkX graph objects.

Parameters:

urban_graph (UrbanGraph) – Tabular urban graph to convert.

Return type:

Any

A directed graph with an edge direction column (oneway) becomes an undirected NetworkX graph whose edges keep that column and their geometry drawn from u to v, as nx_graph2urban_graph() reads them back. An undirected MultiGraph keys the edges of a pair of nodes, not of a direction, so an edge whose key the opposite edge already holds (boarding and alighting, two one-way carriageways) gets the next free key.

Return type:

Any

Returns:

networkx.Graph, networkx.DiGraph, networkx.MultiGraph or networkx.MultiDiGraph with node and edge attributes copied from the UrbanGraph tables.

Raises:

ValueError – If a graph without parallel edges would become an undirected networkx.Graph while two of its edges join the same nodes (u to v and v to u): such a graph holds one of them only.

Parameters:

urban_graph (UrbanGraph)