3.8. kda.graph_utils
3.8.1. Graph Utilities
This file contains a host of utility functions for NetworkX graphs.
- generate_edges(G, vals, names=None, val_key='val', name_key='name')[source]
Generate edges for an input kinetic diagram
G, where edges have attributes"name"(for rate constant variable names, e.g."k12") and"val"(for the rate constant values, e.g.100).- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagramvals (ndarray) –
NxNarray whereNis the number of nodes inG. Contains the kinetic rate values for each transition inG. For example, assuming we have some valuesk12_valandk21_val, for a 2-state diagramvals = [[0, k12_val], [k21_val, 0]].names (ndarray, optional) –
NxNarray whereNis the number of nodes inG. Contains the kinetic rate variable names (as strings) for each transition inG. For example, for a 2-state diagramnames = [[0, "k12"], ["k21", 0]].val_key (str, optional) – Attribute key used to retrieve kinetic rate values from the edge data stored in
G.edges. The default is"val".name_key (str, optional) – Attribute key used to retrieve kinetic rate variable names from the edge data stored in
G.edges. The default is"name".
- find_all_unique_cycles(G)[source]
Finds all unique cycles in a kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagram- Returns:
unique_cycles – List of cycles, where each cycle is a list of nodes in that cycle.
- Return type:
list of lists of int
- generate_K_string_matrix(N_states)[source]
Creates the string variant of the K-matrix based on the number of states in a diagram.
- Parameters:
N_states (int) – The number of states in a diagram used to create a
NxNmatrix of strings.- Returns:
K_string – An
NxNarray of strings whereNis the number of states in a diagram and the diagonal values of the array are zeros.- Return type:
ndarray
- retrieve_rate_matrix(G, key='val')[source]
Retrieves rate matrix from a kinetic diagram.
- Parameters:
G (
NetworkX.MultiDiGraph) – A kinetic diagramkey (str, optional) – Attribute key used to retrieve edge data from
G.edges. The defaultNetworkXedge key is"weight", however thekdaedge keys are"name"(for rate constant names, e.g."k12") and"val"(for the rate constant values, e.g.100). Default is"val".
- Returns:
rate_matrix –
NxNarray whereNis the number of nodes/states in the diagramG. Contains the values/rates for each edge.- Return type:
ndarray
- get_ccw_cycle(cycle, order)[source]
Function used for obtaining the CCW version of an input cycle, primarily used for
calculate_pi_difference()andcalculate_thermo_force().- Parameters:
cycle (list of int) – List of node indices for cycle of interest, index zero. Order of node indices does not matter.
order (list of int) – List of integers of length 2 (e.g.
[0, 1]), where the integers are nodes incycle. The pair of nodes should be ordered such that a counter-clockwise path is followed.
Functions
Finds all unique cycles in a kinetic diagram. |
|
|
Creates the string variant of the K-matrix based on the number of states in a diagram. |
|
Generate edges for an input kinetic diagram |
|
Function used for obtaining the CCW version of an input cycle, primarily used for |
|
Retrieves rate matrix from a kinetic diagram. |