Expand description
GraphQuery: portable, composable graph query interface.
Ported from Pattern.Graph.GraphQuery in the Haskell reference implementation.
§Overview
GraphQuery<V> is a struct-of-closures representing the complete query interface
over a graph. Algorithms operate against this interface, not against any specific
backing representation. This enables the same algorithm code to run against
PatternGraph, database-backed stores, or any other structure that can produce
the nine required closures.
§Structural Invariants
Implementations of GraphQuery<V> must uphold these invariants:
query_source(r) = Some(s)impliess ∈ query_nodes()query_target(r) = Some(t)impliest ∈ query_nodes()r ∈ query_incident_rels(n)impliesquery_source(r) = Some(n) || query_target(r) = Some(n)query_degree(n) == query_incident_rels(n).len()(default; may be faster indexed)query_node_by_id(n.value.identify()) = Some(n)for alln ∈ query_nodes()query_relationship_by_id(r.value.identify()) = Some(r)for allr ∈ query_relationships()query_containersreturns only direct containers — not transitive containment
Structs§
- Graph
Query - Portable graph query interface: a struct of nine closures.
Enums§
- Traversal
Direction - Which direction along a directed relationship is being traversed.
Functions§
- directed
- Forward cost 1.0, Backward cost INFINITY — follow edge direction only.
- directed_
reverse - Forward cost INFINITY, Backward cost 1.0 — follow edges in reverse only.
- frame_
query - Restrict a
GraphQuery<V>to elements satisfyinginclude. - memoize_
incident_ rels - Wrap
query_incident_relsandquery_degreewith an eager HashMap cache. - undirected
- Uniform cost 1.0 in both directions — treat all edges as bidirectional.
Type Aliases§
- Traversal
Weight - A cost function for traversing a relationship in a given direction.