Graph module#

Graph class container.

class galaxy_graph.graph.Graph(is_directed: bool = True, nodes: set[Node] = <factory>, data: T | None = None)#

Set of nodes.

add(node: Node[__annotationlib_name_1__]) Node[__annotationlib_name_2__]#

Add an offline Node to this Graph.

connect(source: Node, connection: Connection[__annotationlib_name_1__], destination: Node) Connection[__annotationlib_name_2__]#

Add two node with a connection quickly.

The two created node and connection will be added to the graph. If the graph of the node is not directed, each node will have the same connection.

Parameters#

source: Node

First node of the connection. If graph is directed, origin of the arrow

connection: Connection

Connection linking the first and the second node. This connection must not have been already used in another link.

destination: Node

Last node of the connection. If graph is directed, pointing of the arrow.

delete(node_id: str) Node#

Delete a node and all of its connections.

get_by_class(class_: type[Node]) set[Node]#

Get all node of a given class.

get_by_data(predicate: Callable[[__annotationlib_name_1__], __annotationlib_name_2__]) set[Node[__annotationlib_name_3__]]#

Get all node of the graph respecting a condition on its data.

Return every nodes for which applying the node’s data to filter return True.

get_by_id(node_id: str) Node#

Get a node from its node identifier.

internal_add_node(node: Node) None#

Add a node to the graph.

Internal use only.

internal_delete_node(node: Node) None#

Delete a node and all of its connections to other nodes.

Internal use only.