Native adjacency-list graph backend implementing ExOKF.Graph.Backend.
Builds directed edges from internal markdown links between concepts.
Suitable for typical knowledge bundles; swap in ExOKF.Graph.GraphBLAS
for large-scale sparse algebra in v0.2+.
Fields
| Field | Type | Description |
|---|---|---|
outbound | %{optional(String.t()) => MapSet.t(String.t())} | Concept id → set of linked targets. |
inbound | %{optional(String.t()) => MapSet.t(String.t())} | Concept id → set of backlink sources. |
nodes | MapSet.t(String.t()) | All concept ids present when the graph was built. |
Example
%ExOKF.Graph.Adjacency{
outbound: %{"tables/orders" => MapSet.new(["tables/customers", "datasets/sales"])},
inbound: %{"tables/customers" => MapSet.new(["tables/orders", "datasets/sales"])},
nodes: MapSet.new(["tables/orders", "tables/customers", "datasets/sales"])
}
Summary
Functions
Builds an adjacency graph from the bundle's internal links.
Returns true when the directed graph contains a cycle.
Returns the number of directed edges.
Returns all directed edges as {from, to} tuples, sorted.
Returns true when a directed edge from → to exists.
Returns sorted outbound neighbors of id.
Returns the number of concept nodes.
Returns concept ids reachable from id.
Returns sorted inbound neighbors (backlinks) of id.
Types
Functions
@spec build(ExOKF.Bundle.t()) :: t()
Builds an adjacency graph from the bundle's internal links.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> graph = ExOKF.Graph.Adjacency.build(bundle)
iex> "tables/customers" in ExOKF.Graph.Adjacency.neighbors(graph, "tables/orders")
true
Returns true when the directed graph contains a cycle.
Uses DFS with a recursion stack (not plain BFS reachability).
Parameters
graph(t/0) — adjacency graph
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> is_boolean(ExOKF.Graph.Adjacency.cyclic?(bundle.graph.data))
true
@spec edge_count(t()) :: non_neg_integer()
Returns the number of directed edges.
Parameters
graph(t/0) — adjacency graph
Returns all directed edges as {from, to} tuples, sorted.
Parameters
graph(t/0) — adjacency graph
Returns true when a directed edge from → to exists.
Parameters
graph(t/0) — adjacency graphfrom(String.t()) — source concept idto(String.t()) — target concept id
Returns sorted outbound neighbors of id.
Parameters
graph(t/0) — adjacency graphid(String.t()) — concept id
@spec node_count(t()) :: non_neg_integer()
Returns the number of concept nodes.
Parameters
graph(t/0) — adjacency graph
Returns concept ids reachable from id.
Parameters
graph(t/0) — adjacency graphid(String.t()) — start concept idopts(keyword()) —:max_depth(pos_integer() \| :infinity) and:include_self(boolean())
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> g = bundle.graph.data
iex> "tables/customers" in ExOKF.Graph.Adjacency.reachable(g, "tables/orders", max_depth: 1)
true
Returns sorted inbound neighbors (backlinks) of id.
Parameters
graph(t/0) — adjacency graphid(String.t()) — concept id