graph.py¶
graph.py - Contains the CircuitGraph class for handling all graph operations.
- class app.graph.CircuitGraph(xml_file_path='')¶
This class organizes graph construction when documenting circuits. Note that it inherits NetworkX’s Graph class; thus, able to use methods and properties of that class.
- add_edges(edges)¶
Adds list of edges to graph. Edges should be formatted as per below. (“id_from”, “id_to”, {“directed”: True})
- Parameters
edges (
List[tuple]) – list of tuples containing edge info- Return type
None
- add_nodes(nodes)¶
Adds list of nodes to graph. Nodes should be formatted as per below. (“group_#_type_#”, {“type”: “xxx”, “extra_attr”: “xxx”})
- Parameters
nodes (
List[tuple]) – list of tuples containing node info- Return type
None
- draw()¶
Produces a visual graph of circuit
- Return type
None
- find_cycles()¶
Finds any cycles present in graph structure.
- Return type
List- Returns
list of cycles found in graph
- find_paths(from_node, to_node)¶
Finds all paths from one node to another.
- Parameters
from_node (
str) – id of node to start from for path traversalto_node (
str) – id of node to end at for path traversal
- Return type
List- Returns
list of paths from one node to another