Skip to main content

Module algorithms

Module algorithms 

Source
Expand description

Graph algorithms operating against the GraphQuery<V> interface.

Ported from Pattern.Graph.Algorithms in the Haskell reference implementation.

All functions are representation-independent: they operate on GraphQuery<V> closures only. The same code works against PatternGraph, in-memory closures, or any future backing store.

§Traversal weight semantics

Pass a TraversalWeight<V> to control which edges are traversable and at what cost. Use the canonical functions undirected, directed, or directed_reverse, or supply a custom Rc<dyn Fn(...)>.

An edge with INFINITY cost in a given direction is impassable in that direction.

Functions§

all_paths
Enumerate all simple paths from from to to (no repeated nodes).
betweenness_centrality
Betweenness centrality using the Brandes BFS algorithm (unnormalized).
bfs
Breadth-first traversal from start.
connected_components
Partition the graph into connected components.
degree_centrality
Degree centrality for all nodes.
dfs
Depth-first traversal from start.
has_cycle
Returns true if the graph contains a directed cycle.
has_path
Returns true if a path exists from from to to.
is_connected
Returns true if the entire graph is connected under weight.
is_neighbor
Returns true if b is directly reachable from a in one hop under weight.
minimum_spanning_tree
Minimum spanning tree using Kruskal’s algorithm with path-compression union-find.
query_annotations_of
Returns all containers of element that are classified as annotations.
query_co_members
Returns all elements that share container with element, excluding element itself.
query_walks_containing
Returns all containers of element that are classified as walks.
shortest_path
Find the minimum-cost path from from to to using Dijkstra’s algorithm.
topological_sort
Topological sort using iterative DFS post-order with cycle detection.