Python · Graphs

Graphs

import ustorefrom ustore import Neighborhoods 1.0.0-rc.1 · d6d40961

graph_write_edges, graph_remove_edges, graph_write_vertices and graph_remove_vertices edit a graph collection, while graph_read_edges answers Neighborhoods and graph_degrees the degree of every vertex, with None where a vertex is absent. An edge is a source, a target and an optional identifier, so distinct identifiers let a pair of vertices share several edges, and one without an identifier takes ustore.edge_id_default. ustore.graph_view.DiGraph and Graph mirror NetworkX over these verbs and over document collections holding the attributes of vertices and edges.

API

Types

RoleThe role a vertex plays in an edge, valued as ustore_vertex_role_t.
__init__.py:239 ↗
class Role(IntEnum)

Values

UNKNOWN0
SOURCE1
TARGET2
ANY3
ClassNeighborhoodsThe edges one batch read found around its vertices, viewing its Arena until it rewinds.3
lib.pyi:513 ↗
class Neighborhoods
__dlpack__A DLPack capsule over the memory the buffer protocol exports, pinning the arena until its consumer deletes it, so numpy.from_dlpack reads it in place.
lib.pyi:521 ↗
def __dlpack__(
    *,
    stream: object | None = None,
    max_version: tuple[int, int] | None = None,
    dl_device: tuple[int, int] | None = None,
    copy: bool | None = None,
) -> object
__dlpack_device__The DLPack device of the arena: (1, 0) for host pages, (2, ordinal) for NVIDIA, (10, ordinal) for AMD.
lib.pyi:532 ↗
def __dlpack_device__() -> tuple[int, int]
degrees
lib.pyi:516 ↗
degrees: tuple[int | None, ...]

Constants

edge_id_default
__init__.py:71 ↗
edge_id_default: UUID