sampo.schemas.graph#
Overview#
Class to define a certain type of edge in graph |
|
The edge of graph with start and finish vertexes |
|
Class to describe Node in graph |
|
Class to describe graph of works |
- |
Classes#
- class sampo.schemas.graph.EdgeType#
Bases:
enum.EnumClass to define a certain type of edge in graph
- InseparableFinishStart = 'IFS'#
- LagFinishStart = 'FFS'#
- StartStart = 'SS'#
- FinishFinish = 'FF'#
- FinishStart = 'FS'#
- static is_dependency(edge) bool#
- class sampo.schemas.graph.GraphEdge#
The edge of graph with start and finish vertexes
- lag: float | None = 0#
- class sampo.schemas.graph.GraphNode(work_unit: sampo.schemas.works.WorkUnit, parent_works: list[GraphNode] | list[tuple[GraphNode, float, EdgeType]])#
Bases:
sampo.schemas.serializable.JSONSerializable[GraphNode]Class to describe Node in graph
- property edges_from: list[GraphEdge]#
Return all successors of current vertex :return: list of successors
- property work_unit: sampo.schemas.works.WorkUnit#
- property id: str#
- __del__()#
- __hash__() int#
Return hash(self).
- __repr__() str#
Return repr(self).
- __getstate__()#
- __setstate__(state)#
- _serialize() sampo.schemas.serializable.T#
Converts all the meaningful information from this instance to a generic representation :return: A generic representation
- classmethod _deserialize(representation: sampo.schemas.serializable.T) dict#
Creates class instance from a representation :param representation: Representation produced by _serialize method :return: New class instance
- update_work_unit(work_unit: sampo.schemas.works.WorkUnit) None#
- add_parents(parent_works: list['GraphNode'] or list[tuple['GraphNode', float, EdgeType]]) None#
Two-sided linking of successors and predecessors
- Parameters:
parent_works – list of parent works
- invalidate_parents_cache()#
- invalidate_children_cache()#
- is_inseparable_parent() bool#
- is_inseparable_son() bool#
- traverse_children(topologically: bool = False)#
DFS from current vertex to down :param topologically: is DFS need to go in topologically way :return:
- inseparable_son() GraphNode | None#
Return inseparable son (amount of inseparable sons at most 1) :return: inseparable son
- inseparable_parent() GraphNode | None#
Return predecessor of current vertex in inseparable chain :return: inseparable parent
- neighbors()#
Get all edges that have types SS with current vertex :return: list of neighbours
- get_inseparable_chain() list[GraphNode] | None#
Gets an ordered list of whole chain of nodes, connected with edges of type INSEPARABLE_FINISH_START = ‘INSEPARABLE’, IF self NODE IS THE START NODE OF SUCH CHAIN. Otherwise, None.
- Returns:
list of GraphNode or None
- get_inseparable_chain_with_self() list[GraphNode]#
Gets an ordered list of whole chain of nodes, connected with edges of type INSEPARABLE_FINISH_START = ‘INSEPARABLE’.
- Returns:
list of inseparable chain with starting node
- _get_inseparable_children() list[GraphNode]#
Recursively gets a child, connected with INSEPARABLE_FINISH_START edge, its inseparable child, etc. As any node may contain an inseparable connection with only one of its children, there is no need to choose. If no children are connected inseparably, returns None.
- Returns:
list[GraphNode]. Empty, if there is no inseparable children
- _add_child_edge(child: GraphEdge)#
Append new edge with child
- Parameters:
child –
- Returns:
current graph node
- min_start_time(node2swork: dict[GraphNode, sampo.schemas.scheduled_work.ScheduledWork]) sampo.schemas.time.Time#
- class sampo.schemas.graph.WorkGraph#
Bases:
sampo.schemas.serializable.JSONSerializable[WorkGraph]Class to describe graph of works
- adj_matrix: scipy.sparse.dok_matrix#
- dict_nodes: GraphNodeDict#
- vertex_count: int#
- __post_init__() None#
- reinit()#
- __hash__()#
Return hash(self).
- __getstate__()#
- __setstate__(state)#
- __del__()#
- _serialize() sampo.schemas.serializable.T#
Converts all the meaningful information from this instance to a generic representation :return: A generic representation
- classmethod _deserialize(representation: sampo.schemas.serializable.T) sampo.schemas.serializable.JS#
Creates class instance from a representation :param representation: Representation produced by _serialize method :return: New class instance
Attributes#
- sampo.schemas.graph.GraphNodeDict#