Skip to content

InMemoryGraphStore

InMemoryGraphStore()

Bases: GraphStore

A GraphStore keeping its edges in memory (as np.ndarray).

Example:

from mlx_graphs.data import InMemoryGraphStore

graph_store = InMemoryGraphStore.from_data(data)

Methods:

Name Description
from_data

A store holding the edges of a GraphData.

Source code in mlx_graphs/data/graph_store.py
def __init__(self):
    super().__init__()
    self._edges: dict[Any, tuple[EdgeAttr, tuple[np.ndarray, np.ndarray]]] = {}

from_data classmethod

from_data(data: Any) -> InMemoryGraphStore

A store holding the edges of a GraphData.

Source code in mlx_graphs/data/graph_store.py
@classmethod
def from_data(cls, data: Any) -> "InMemoryGraphStore":
    """A store holding the edges of a :class:`~mlx_graphs.data.GraphData`."""
    store = cls()
    n = data.num_nodes
    store.put_edge_index(data.edge_index, layout="coo", size=(n, n))
    return store

from mlx_graphs.data import InMemoryGraphStore · mlx_graphs/data/graph_store.py