Graph¶
-
class
orion_notebook.graph.graph.
Graph
(nodes: List[orion_notebook.graph.nodes.node.Node], edges: List[orion_notebook.graph.edges.edge.Edge])¶ Bases:
object
Class to manage all objects inside graph
-
add
(nodes: List[orion_notebook.graph.nodes.node.Node], edges: List[orion_notebook.graph.edges.edge.Edge])¶ Adds a list of nodes and edges to the current Graph instance
Retrieves the context menu of two nodes and intersects their elements, resetting the children count and ordering them accordingly
- Parameters
nodes_ids (List[str]) – List of nodes identifiers
function_to_execute (Callable) – function to execute on the node
- Returns
Returns the list of menu items for the given nodes
- Return type
List[MenuItem]
Gets the common items of two menus
-
create_checkpoint
(reset_history: bool = False)¶ Creates a new point in history
- Parameters
reset_history (bool) – flag to reset the history (default False)
-
edges
: List[orion_notebook.graph.edges.edge.Edge]¶
-
exist_edge
(edge: orion_notebook.graph.edges.edge.Edge) → bool¶ Checks if a edge exists within the graph
- Parameters
edge (Edge) – Edge to check for
- Returns
If the edges exists
- Return type
bool
-
exist_node
(node_id: str) → bool¶ Checks if a node exists within the graph (by its id)
- Parameters
node_id (str) – the id of the node to check for
- Returns
If the edges exists
- Return type
bool
-
get_children_count_for_nodes
()¶
Gets the context menu for the given nodes
- Parameters
nodes_ids (List) – List of nodes to get context menu from
- Returns
Context menu for the given nodes (their id and options)
- Return type
object
-
get_edge_by_id
(edge_id: str) → Optional[orion_notebook.graph.edges.edge.Edge]¶ Get Edge by its id
- Parameters
edge_id (str) – Id of the edge to fetch
- Returns
Edge with the provided Id (if found)
- Return type
Optional[Edge]
-
get_edge_info
(edge_id: str) → orion_notebook.graph.edges.edge.Edge¶ Sets the details for the edge by its id and returns it
- Returns
Edge with the provided id with fetched details
- Return type
-
get_history_state
()¶ Returns the current state of the history (whether if a undo/redo could occur or not)
- Returns
dict with two entries, if the Graph can perform an undo and a redo
- Return type
dict
-
get_node_by_id
(node_id: str) → Optional[orion_notebook.graph.nodes.node.Node]¶ Get Node by its id
- Parameters
node_id (str) – Id of the node to fetch
- Returns
Node with the provided Id (if found)
- Return type
Optional[Node]
-
get_node_edges
(node_id: str) → List[orion_notebook.graph.edges.edge.Edge]¶ Returns the edges connected with a node (by its id)
- Returns
Edges connected to the node with the provided id
- Return type
List[Edge]
-
get_node_info
(node_id: str) → orion_notebook.graph.nodes.node.Node¶ Sets the details for the node by its id and returns it
- Returns
Node with the provided id with fetched details
- Return type
-
layers_visibility
: orion_notebook.graph.graph_layers_visibility.GraphLayersVisibility¶
-
layout
: str¶
-
nodes
: List[orion_notebook.graph.nodes.node.Node]¶
-
orion_version
: str¶
-
redo
()¶ Performs a redo in the Graph instance, advancing to the next state in the history (if available)
-
remove_edge
(edge: orion_notebook.graph.edges.edge.Edge)¶ Remove edge from graph
- Parameters
edge (Edge) – Edge to remove from the graph
- Raises
Exception – Edge does not exist
-
remove_node
(node: orion_notebook.graph.nodes.node.Node)¶ Remove node from graph
- Parameters
node (Node) – Node to remove from the graph
- Raises
Exception – Node does not exist
-
remove_nodes
(nodes_ids: List[str]) → List[str]¶ Remove the given nodes from the graph, it also removes the corresponding children and edges
- Parameters
nodes_ids (List[str]) – Ids of nodes to remove
- Returns
Node Ids removed
- Return type
List[str]
-
rename_node
(node_id: str, new_name: str)¶ Sets a new name for the node with the id provided
- Parameters
node_id (str) – Id of the node to rename
new_name (str) – New name for the node
-
set_history_state
(history: orion_notebook.graph.history_wrapper.HistoryWrapper)¶ Sets the history of the Graph instance, overwriting the actual one
- Parameters
history (HistoryWrapper) – HistoryWrapper object with all the new entries of the Graph states
-
undo
()¶ Performs a undo in the Graph instance, moving back in the state of the history (if available)
-