nocad.annotation.annotate#

nocad.annotation.annotate(adj, design=None, *, method='path_finding', drivers=None, sensors=None, labels=None, centrality=False, robustness=False)[source]#

Node and edge tables with the controllability and observability role of every element.

Parameters:
adjnetwork

Adjacency matrix, sparse matrix, networkx.DiGraph or pandas.DataFrame; node names of graphs and data frames become the labels.

designInputOutputDesign, optional

A fitted design; designed with method when omitted.

methodstr, default=”path_finding”

Design method if design is None (see InputOutputDesign).

drivers, sensorsarray_like of int, optional

Configuration to annotate instead of the design’s nodes (for example the result of a Placement); matchings and cacti still come from the design.

labelslist of str, optional

Node names (default: names of the input graph, else x1, x2, ...).

centralitybool, default=False

Add control_centrality and observe_centrality (generic ranks).

robustnessbool, default=False

Add control_critical / observe_critical: the loss of the node destroys structural controllability / observability of the configuration.

Returns:
resultBunch with nodes and edges (pandas DataFrames, columns described in

NODE_COLUMNS and EDGE_COLUMNS), graph (dict of network-level values) and design.

Examples

>>> from nocad.datasets import load_nocad_example
>>> ann = annotate(load_nocad_example().adj)
>>> ann.nodes.loc[ann.nodes.driver, ["label", "control_role", "driver_type"]].values.tolist()
[['x8', 'critical', 'source']]
>>> ann.edges.query("control_cactus == 'stem'")[["source", "target"]].values.tolist()
[['x6', 'x7'], ['x7', 'x9'], ['x8', 'x6']]