pydent.planner.PlannerLayout¶
-
class
pydent.planner.PlannerLayout(nxgraph=None)[source]¶ Bases:
pydent.planner.graph.PlannerGraphLayout module for
Planner.Positions
Operationsfor the Aquarium GUIInitializes a Plan graph.
- Parameters
nxgraph (
Optional[DiGraph]) –
-
__init__(nxgraph=None)¶ Initializes a Plan graph.
- Parameters
nxgraph (
Optional[DiGraph]) –
Methods
__init__([nxgraph])Initializes a Plan graph.
Aligns the Operations to their predecessors by midpoints.
Aligns the Operations to their successors by midpoints.
align_x_midpoints_to(other_layout)Align the midpoint x-coordinate of this layout with that of another.
align_x_of_ops(ops1, ops2)Aligns a set of Operations with another set of Operations within this PlannerLayout.
align_y_midpoints_to(other_layout)Align this midpoint y-coordinates of this layout with another layout.
arrange_layouts(layouts)bounds()Returns the bounding box of the layout as the upper-left and lower- right coordinates.
center(x, y)collect_predecessors(nodes)Return all predecessors from a list of nodes.
collect_successors(nodes)Return all successors from a list of nodes.
draw()from_plan(plan)Creates a graph from a
pydent.models.Planinstance.PlannerLayout.get_independent_layoutsiter_operations()- rtype
Generator[Tuple[Union[str,int],Operation],None,None]
leaves()Returns the leaves of this graph.
midpoint()Returns the midpoint x,y coordinates of the layout.
move(x, y)nodes_to_ops(nodes)Returns operations from a list of node_ids.
PlannerLayout.ops_to_layoutops_to_leaves()ops_to_nodes(ops)Returns node_ids for each operation.
ops_to_predecessors(ops)Return all predecessor operations from a list of operations.
ops_to_roots()ops_to_successors(ops)Return all successor operations from a list of operations.
pos()- rtype
Dict[Union[str,int],Tuple[float,float]]
PlannerLayout.predecessor_layoutpredecessors(node)Return predecessor nodes.
prettify()roots()Returns the roots of this graph.
subgraph(nodes)Returns a subgraph layout from a list of node_ids.
PlannerLayout.successor_layoutsuccessors(node)Return successors nodes.
to_grid(columns[, axis, border_x, border_y])Arrange layouts in a grid format.
Does a topological sort of the operations in this layout.
topo_sort_in_place()translate(delta_x, delta_y)Translates the layout by the x,y coordinates.
Attributes
BOX_DELTA_XBOX_DELTA_YBOX_HEIGHTBOX_WIDTHSTATUS_COLORSTOP_RIGHTheight- rtype
float
nodesoperations- rtype
Generator[Operation,None,None]
widthx- rtype
float
xy- rtype
Tuple[float,float]
y- rtype
float
-
_add_operation(op)¶ Adds an Operation to the Layout.
- Parameters
op (pydent.models.Operation) – operation
- Returns
None
- Return type
None
-
align_ops_with_predecessors(ops)[source]¶ Aligns the Operations to their predecessors by midpoints.
Used in topological sorting of plans.
- Parameters
ops (list) – list of
pydent.models.Operation- Returns
None
- Return type
None
-
align_ops_with_successors(ops)[source]¶ Aligns the Operations to their successors by midpoints.
Used in topological sorting of plans.
- Parameters
ops (list) – list of
pydent.models.Operation- Returns
None
- Return type
None
-
align_x_midpoints_to(other_layout)[source]¶ Align the midpoint x-coordinate of this layout with that of another.
- Parameters
other_layout (PlannerLayout) – the other canvas layout
- Returns
None
- Return type
None
-
align_x_of_ops(ops1, ops2)[source]¶ Aligns a set of Operations with another set of Operations within this PlannerLayout.
- Parameters
ops1 (list) – list of
pydent.models.Operationops2 (list) – list of
pydent.models.Operation
- Returns
None
- Return type
None
-
align_y_midpoints_to(other_layout)[source]¶ Align this midpoint y-coordinates of this layout with another layout.
- Parameters
other_layout (PlannerLayout) – the other canvas layout
- Returns
None
- Return type
None
-
bounds()[source]¶ Returns the bounding box of the layout as the upper-left and lower- right coordinates.
- Returns
x,y coordinate
- Return type
tuple
-
collect_predecessors(nodes)¶ Return all predecessors from a list of nodes.
- Parameters
nodes (list) – list of node ids
- Returns
list of node ids
- Return type
list
-
collect_successors(nodes)¶ Return all successors from a list of nodes.
- Parameters
nodes (list) – list of node ids
- Returns
list of node ids
- Return type
list
-
classmethod
from_plan(plan)¶ Creates a graph from a
pydent.models.Planinstance.- Return type
PlannerGraph
-
get_independent_graphs()[source]¶ Finds all independent subgraphs.
- Returns
list of PlannerLayout
- Return type
list
-
leaves()¶ Returns the leaves of this graph.
-
midpoint()[source]¶ Returns the midpoint x,y coordinates of the layout.
- Returns
x,y coordinate
- Return type
tuple
-
nodes_to_ops(nodes)¶ Returns operations from a list of node_ids.
-
ops_to_nodes(ops)¶ Returns node_ids for each operation.
-
ops_to_predecessors(ops)¶ Return all predecessor operations from a list of operations.
- Parameters
ops (list) – list of
pydent.models.Operation- Returns
list of node ids
- Return type
list
-
ops_to_subgraph(ops)¶ Returns a sub-layout containing only the operations.
- Return type
PlannerGraph
-
ops_to_successors(ops)¶ Return all successor operations from a list of operations.
- Parameters
ops (list) – list of
pydent.models.Operation- Returns
list of node ids
- Return type
list
-
predecessors(node)¶ Return predecessor nodes.
- Parameters
node (basestring) – node id
- Returns
list of node ids
- Return type
list
-
roots()¶ Returns the roots of this graph.
-
subgraph(nodes)¶ Returns a subgraph layout from a list of node_ids.
- Return type
Optional[Type[PlannerGraph]]
-
successors(node)¶ Return successors nodes.
- Parameters
node (basestring) – node id
- Returns
list of node ids
- Return type
list
-
to_grid(columns, axis=1, border_x=None, border_y=None)[source]¶ Arrange layouts in a grid format.
- Parameters
columns (int) – maximum number of columns (or rows when axis=0)
axis (int) – which axis to limit. Default: 1 (columns) or 0 (rows)
border_x (int) – (optional) separation between each cell in the grid
border_y (int) – (optional) separation between each cell in the grid
- Returns
layout
- Return type
layout