Traversal¶
Hypabase provides methods for navigating the hypergraph: finding neighbors, discovering paths, and querying incident edges.
Neighbors¶
Find all nodes connected to a given node through any shared edge:
Filter by edge type¶
# Only neighbors connected via treatment edges
neighbors = hb.neighbors("patient_123", edge_types=["treatment"])
The result excludes the query node itself.
Paths¶
Find paths between two nodes through hyperedges:
paths = hb.paths("dr_smith", "mercy_hospital")
# [["dr_smith", "patient_123", "mercy_hospital"], ...]
Each path is a list of node IDs from start to end.
Limit hop count¶
The default max_hops is 5.
Filter by edge type¶
# Only traverse treatment and diagnosis edges
paths = hb.paths(
"dr_smith",
"mercy_hospital",
edge_types=["treatment", "diagnosis"],
)
Advanced path finding¶
find_paths() provides intersection-constrained path finding — it returns paths as sequences of edges rather than node IDs, and supports set-based start/end nodes:
paths = hb.find_paths(
start_nodes={"dr_smith", "dr_jones"},
end_nodes={"mercy_hospital"},
max_hops=3,
max_paths=10,
edge_types=["treatment"],
)
# Returns list of list[Edge]
Parameters:
start_nodes— set of possible start node IDsend_nodes— set of possible end node IDsmax_hops— longest path length allowed (default 3)max_paths— cap on paths returned (default 10)min_intersection— required node overlap between consecutive edges (default 1)edge_types— filter to specific edge typesdirection_mode—"undirected"(default),"forward", or"backward"
Edges of a node¶
Get all edges incident to a specific node:
Filter by edge type:
Graph metrics¶
Node degree¶
Number of edges incident to a node:
Filter by edge type:
Edge cardinality¶
Number of unique nodes in an edge:
Hyperedge degree¶
Sum of vertex degrees of nodes in a given set: