Skip to content

Graph

Graph

Bases: Protocol, Generic[Node]

The graph interface.

This interface defines the methods that a graph object must implement. The graph interface is mainly for compatibility reasons so that one can use multiple graph implementations interchangeably.

get_edges

get_edges() -> Iterable[tuple[Node, Node]]

Get all the edges in the graph.

Source code in src/kirin/graph.py
26
27
28
def get_edges(self) -> Iterable[tuple[Node, Node]]:
    """Get all the edges in the graph."""
    ...

get_neighbors

get_neighbors(node: Node) -> Iterable[Node]

Get the neighbors of a node.

Source code in src/kirin/graph.py
18
19
20
def get_neighbors(self, node: Node) -> Iterable[Node]:
    """Get the neighbors of a node."""
    ...

get_nodes

get_nodes() -> Iterable[Node]

Get all the nodes in the graph.

Source code in src/kirin/graph.py
22
23
24
def get_nodes(self) -> Iterable[Node]:
    """Get all the nodes in the graph."""
    ...