vcorelib.graph package#
Submodules#
vcorelib.graph.abc module#
A module containing abstract base-classes related to graphs.
- class vcorelib.graph.abc.AbstractDiGraph(name: str, initialdata: Dict[str, T] = None, graph_attrs: Dict[str, str] = None, node_attrs: Dict[str, str] = None, edge_attrs: Dict[str, str] = None)[source]#
Bases:
UserDict
,Serializable
A simple, directed-graph interface.
- add_edge(src: str, dst: str, src_port: str = None, dst_port: str = None, strict: bool = False, **attrs) None [source]#
Add an edge between nodes in the graph.
- add_parallel(node1: str, node2: str, src_port1: str = None, dst_port1: str = None, src_port2: str = None, dst_port2: str = None, **kwargs) None [source]#
Add an edge in each direction for two nodes.
- class vcorelib.graph.abc.AbstractDiGraphNode(graph: V = None, label: str = None, port: Port = None, **attrs)[source]#
Bases:
Serializable
A base interface for a directed-graph node.
- incoming(graph_kind: Type[V] = None) Iterator[T] [source]#
Iterate over nodes that have incoming edges.
- property label: str#
Get this node’s label.
vcorelib.graph.edge module#
A module for defining and working with graph edges.
- class vcorelib.graph.edge.GraphEdge(src: str, dst: str, src_port: Port | None = None, dst_port: Port | None = None, attrs: Dict[str, str] | None = None)[source]#
Bases:
NamedTuple
A grouping of attributes describing a directed edge in a graph.
- attrs: Dict[str, str] | None#
Alias for field number 4
- dst: str#
Alias for field number 1
- src: str#
Alias for field number 0
vcorelib.graph.node module#
A module for working with graph nodes.
- class vcorelib.graph.node.DiGraphNode(graph: V = None, label: str = None, port: Port = None, **attrs)[source]#
Bases:
AbstractDiGraphNode
A base implementation for a directed-graph node.
- add_child(label: str, node: T = None, graph_kind: Type[V] = None, **kwargs) T [source]#
Add an edge between this node (source) and the other node (destination).
- add_parallel(label: str, node: T = None, graph_kind: Type[V] = None, **kwargs) T [source]#
Add a parallel edge between two nodes. This instance is used as ‘node1’.
vcorelib.graph.port module#
A module for working with graph ports.
- class vcorelib.graph.port.Port(label: str, kind: PortType = PortType.INOUT, alias: str | None = None, allocated: bool = False)[source]#
Bases:
NamedTuple
A simple implementation for generic, input and output ports.
- alias: str | None#
Alias for field number 2
- allocated: bool#
Alias for field number 3
- property is_input: bool#
Determine if this is an input port.
- property is_output: bool#
Determine if this is an output port.
- label: str#
Alias for field number 0
- class vcorelib.graph.port.PortManager[source]#
Bases:
object
An interface for managing input and output ports.
- class vcorelib.graph.port.PortType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
An enumeration of port types.
- INOUT = 3#
- INPUT = 1#
- OUTPUT = 2#
- property is_input: bool#
Determine if this port type is capable of input.
- property is_output: bool#
Determine if this port type is capable of output.
Module contents#
A module for implementing graph-like data structures.
See Graphviz’s ‘DOT Language’ here: https://graphviz.org/doc/info/lang.html.
- class vcorelib.graph.DiGraph(name: str, initialdata: Dict[str, T] = None, graph_attrs: Dict[str, str] = None, node_attrs: Dict[str, str] = None, edge_attrs: Dict[str, str] = None)[source]#
Bases:
AbstractDiGraph
A simple, directed-graph implementation.