nocad.io.to_networkx#
- nocad.io.to_networkx(adj, labels=None, *, annotate=True, design=None, method='path_finding', drivers=None, sensors=None, node_ids='label', layout=None, weights=None, centrality=False, robustness=False)[source]#
NetworkX digraph of a network, with the annotations as node and edge attributes.
- Parameters:
- adj
networkorInputOutputDesign - labels
listofstr,optional Node names (default: names of the input graph, else
x1, x2, ...).- annotatebool, default=True
Add the columns of
nocad.annotation.annotate()as attributes; graph attributes hold the network-level values.- design, method, drivers, sensors, centrality, robustness
Passed to
annotate().- node_ids{“label”, “index”}, default=”label”
Use the labels or the integer indices as node identifiers (the label is always stored in the
labelattribute).- layout{“hierarchy”, “default”, …}
orndarrayofshape(N, 2),optional Store positions as
xandynode attributes.- weightsarray_like,
optional Numeric adjacency matrix; its entries are stored as the
weightedge attribute.
- adj
- Returns:
Examples
>>> from nocad.datasets import load_nocad_example >>> G = to_networkx(load_nocad_example().adj) >>> G.nodes["x8"]["io_role"], G.edges["x8", "x6"]["control_cactus"], G.graph["n_inputs"] ('driver', 'stem', 1)