otx.core.ov.graph#
Module for otx.core.ov.graph.
Classes
|
Graph class. |
- class otx.core.ov.graph.Graph(*args, **kwargs)[source]#
Bases:
MultiDiGraph
Graph class.
Initialize a graph with edges, name, or graph attributes.
- Parameters:
incoming_graph_data (input graph) – Data to initialize graph. If incoming_graph_data=None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a 2D NumPy array, a SciPy sparse matrix, or a PyGraphviz graph.
multigraph_input (bool or None (default None)) – Note: Only used when incoming_graph_data is a dict. If True, incoming_graph_data is assumed to be a dict-of-dict-of-dict-of-dict structure keyed by node to neighbor to edge keys to edge data for multi-edges. A NetworkXError is raised if this is not the case. If False,
to_networkx_graph()
is used to try to determine the dict’s graph data structure as either a dict-of-dict-of-dict keyed by node to neighbor to edge data, or a dict-of-iterable keyed by node to neighbors. If None, the treatment for True is tried, but if it fails, the treatment for False is tried.attr (keyword arguments, optional (default= no attributes)) – Attributes to add to graph as key=value pairs.
See also
convert
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G = nx.Graph(name="my graph") >>> e = [(1, 2), (2, 3), (3, 4)] # list of edges >>> G = nx.Graph(e)
Arbitrary graph attribute pairs (key=value) may be assigned
>>> G = nx.Graph(e, day="Friday") >>> G.graph {'day': 'Friday'}
- adjlist_outer_dict_factory#
alias of
SortedDictHelper
- add_edge(node_from: Operation, node_to: Operation, out_port: int | None = None, in_port: int | None = None, **kwargs)[source]#
Graph’s add_edge function.
- bfs(node: Operation, reverse: bool = False, depth_limit: int | None = None) Generator[Tuple[Operation, Operation] | Tuple[Operation, Tuple[Operation]], None, None] [source]#
Graph’s bfs function.
- clean_up(nodes_to_keep: List[Operation] | None = None, remove_sub_components: bool = True)[source]#
Graph’s clean_up function.
- get_edge_data(node_from: Operation, node_to: Operation, default=None) List[Dict[Any, Any]] | None [source]#
Graph’s get_edge_data function.
- get_nodes_by_type_pattern(pattern: List[str], start_node: Operation | None = None, reverse=False)[source]#
Graph’s get_nodes_by_type_pattern function.
- predecessors(node: Operation, with_edge_data: bool = False) Generator[Tuple[Operation, List | None] | Operation, None, None] [source]#
Graph’s predecessors function.