3.3. kda.diagrams
3.3.1. Diagram Generation
The diagrams module contains code to generate partial diagrams
(undirected spanning trees), directional diagrams, and flux diagrams using the
diagram method developed by King and Altman [1]
and Hill [2].
- enumerate_partial_diagrams(G)[source]
Quantifies the number of partial diagrams (undirected spanning trees) that can be generated from a kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagram- Returns:
n_partials – The number of unique partial diagrams (spanning trees) that can be generated from a graph represented by the input rate matrix.
- Return type:
int
Notes
This implements Kirchhoff’s matrix theroem [3] by generating the adjacency matrix from the input diagram, generating the Laplacian matrix from the adjacency matrix, then getting the cofactor matrix of the Laplacian matrix. All cofactors are equal and equal to the number of undirected spanning trees.
A more sophistocated version of this function is available in the
NetworkXlibrary [4] (see here).
- generate_partial_diagrams(G, return_edges=False)[source]
Generates all partial diagrams (undirected spanning trees) for a kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagramreturn_edges (bool) – Binary used for determining whether to return
NetworkXdiagram objects (primarily for plotting) or the edge tuples (generally for calculations).
- Returns:
partials – Array of
NetworkX.Graphwhere each graph is a unique partial diagram with no loops (return_edges=False), or a nested array of unique edges for valid partial diagrams (return_edges=True).- Return type:
ndarray of
NetworkX.Graph
- generate_directional_diagrams(G, return_edges=False)[source]
Generates all directional diagrams for a kinetic diagram using depth-first-search algorithm.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagramreturn_edges (bool) – Binary used for determining whether to return
NetworkXgraph objects (primarily for plotting) or the edge tuples (generally for calculations).
- Returns:
directional_diagrams – Array of all directional diagram edges made from 3-tuples (
return_edges=True) or array of all directional diagrams (return_edges=False) forG.- Return type:
ndarray or ndarray of
NetworkX.DiGraph
- generate_flux_diagrams(G, cycle)[source]
Generates all flux diagrams for a specific cycle in the kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagramcycle (list of int) – List of node indices for cycle of interest, index zero. Order of node indices does not matter.
- Returns:
flux_diagrams – List of flux diagrams. Diagrams contain the input cycle where remaining edges follow path pointing to
cycle. Cycle nodes are labeled by attribute'is_target'.- Return type:
list of
NetworkX.MultiDiGraph
- generate_all_flux_diagrams(G)[source]
Generates all flux diagrams for a kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagram- Returns:
all_flux_diagrams – List of lists of flux diagrams, where each list is for a different cycle in
G.- Return type:
list of lists of
NetworkX.MultiDiGraph
References
Functions
Quantifies the number of partial diagrams (undirected spanning trees) that can be generated from a kinetic diagram. |
|
Generates all flux diagrams for a kinetic diagram. |
|
|
Generates all directional diagrams for a kinetic diagram using depth-first-search algorithm. |
|
Generates all flux diagrams for a specific cycle in the kinetic diagram. |
|
Generates all partial diagrams (undirected spanning trees) for a kinetic diagram. |