Interoperability#

nocad keeps the names of the nodes and converts networks, systems and annotated configurations in both directions. Wherever a network is expected, a NumPy array, a SciPy sparse matrix, a NetworkX graph, an igraph graph (via nocad.io.from_igraph()) or a pandas DataFrame can be passed; node names become the labels of every table and figure, and positions may be NetworkX pos dictionaries.

Role annotations#

nocad.annotate() returns two pandas tables. The node table tells for every state variable whether it is a driver or sensor node (and through which input or output), its role across all maximum matchings (critical, intermittent, redundant), its driver or sensor type, its strongly connected component and level of the hierarchy, its control and observation depth and region, and its part in the control and observation cacti. The edge table tells whether an edge is matched, its class across all maximum matchings (critical, ordinary, redundant), its part in the cacti and its connection type. A classes column joins the categorical roles for style sheets (Cytoscape.js).

import networkx as nx
import nocad

G = nx.DiGraph([("feed", "reactor"), ("reactor", "reactor"), ("reactor", "flash"),
                ("flash", "recycle"), ("recycle", "reactor"), ("flash", "product")])
design = nocad.InputOutputDesign("minimum").fit(G)
ann = design.annotate(robustness=True)
ann.nodes[["label", "io_role", "control_role", "control_depth", "control_critical"]]
nocad.viz.plot_annotation(G, "control_role", ann)

Files#

nocad.write_network() and nocad.read_network() choose the format by the extension; every export carries the annotations as attributes and every file written by nocad is read back with its configuration (net.drivers, net.sensors).

format

extension

read

write

typical use

GraphML

.graphml

yes

yes

yEd, Cytoscape, NetworkX, igraph

GEXF

.gexf

yes

yes

Gephi, with role colors and positions

GML

.gml

yes

yes

igraph and other network tools

Cytoscape

.cyjs

yes

yes

Cytoscape and Cytoscape.js (classes, positions)

node-link

.json

yes

yes

D3.js and web applications

DOT

.dot

no

yes

Graphviz; components of one level share a rank

Pajek

.net

yes

yes

Pajek

edge list

.edgelist

yes

yes

plain text with the node order in a header

CSV / TSV

.csv

yes

yes

spreadsheets; node table in *_nodes.csv

Excel

.xlsx

yes

yes

node, edge and summary sheets

MATLAB

.mat

yes

yes

the NOCAD MATLAB toolbox: A, B, C, D, labels

NumPy

.npz

yes

yes

compact binary storage

design.write("process.gexf")            # open in Gephi
design.write("process.dot")             # dot -Tpdf process.dot -o process.pdf
design.write("process.csv")             # process.csv (edges) + process_nodes.csv
net = nocad.read_network("process.gexf")

Python objects#

pip install "nocad[interop]" installs python-control, igraph and openpyxl.