Graph indexing and traversal over OKF concept links.
Dispatches to an ExOKF.Graph.Backend implementation. The default is the
native adjacency backend (ExOKF.Graph.Adjacency).
After indexing, bundle.graph is %{backend: module(), data: term()}.
Example
{:ok, bundle} = ExOKF.load("path/to/bundle")
bundle = ExOKF.Graph.index(bundle)
ExOKF.Graph.neighbors(bundle, "tables/orders")
#=> ["datasets/sales", "tables/customers"]
ExOKF.Graph.stats(bundle)
#=> %{nodes: 3, edges: 6, backend: ExOKF.Graph.Adjacency}
Summary
Types
A module implementing ExOKF.Graph.Backend.
Functions
Lists available graph backend modules.
Returns all directed edges {from, to}.
Indexes the bundle's internal links using the given backend.
Returns outbound neighbors of a concept.
Returns concept ids reachable from id.
Returns inbound neighbors (backlinks) of a concept.
Returns graph summary statistics.
Types
@type backend() :: module()
A module implementing ExOKF.Graph.Backend.
Examples
ExOKF.Graph.Adjacency
ExOKF.Graph.GraphBLAS
Functions
@spec backends() :: [module()]
Lists available graph backend modules.
Examples
iex> ExOKF.Graph.backends()
[ExOKF.Graph.Adjacency, ExOKF.Graph.GraphBLAS]
@spec edges(ExOKF.Bundle.t()) :: [{String.t(), String.t()}]
Returns all directed edges {from, to}.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundle
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> {"tables/orders", "tables/customers"} in ExOKF.Graph.edges(bundle)
true
@spec index(ExOKF.Bundle.t(), backend()) :: ExOKF.Bundle.t()
Indexes the bundle's internal links using the given backend.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundlebackend(backend/0) — backend module (defaultExOKF.Graph.Adjacency)
Returns
The same bundle with graph set to %{backend: module(), data: term()}.
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> indexed = ExOKF.Graph.index(bundle, ExOKF.Graph.Adjacency)
iex> indexed.graph.backend
ExOKF.Graph.Adjacency
@spec neighbors(ExOKF.Bundle.t(), String.t()) :: [String.t()]
Returns outbound neighbors of a concept.
Lazily indexes the bundle with the default backend when graph is nil.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundleid(String.t()) — concept id
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> "tables/customers" in ExOKF.Graph.neighbors(bundle, "tables/orders")
true
@spec reachable(ExOKF.Bundle.t(), String.t(), keyword()) :: [String.t()]
Returns concept ids reachable from id.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundleid(String.t()) — start concept idopts(keyword()) — passed to the backend::max_depth(pos_integer() \| :infinity) — hop limit (default:infinity):include_self(boolean()) — includeid(defaultfalse)
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> ExOKF.Graph.reachable(bundle, "tables/orders", max_depth: 1) |> Enum.sort()
["datasets/sales", "tables/customers"]
@spec reverse_neighbors(ExOKF.Bundle.t(), String.t()) :: [String.t()]
Returns inbound neighbors (backlinks) of a concept.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundleid(String.t()) — concept id
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> "tables/orders" in ExOKF.Graph.reverse_neighbors(bundle, "tables/customers")
true
@spec stats(ExOKF.Bundle.t()) :: %{ nodes: non_neg_integer(), edges: non_neg_integer(), backend: module() }
Returns graph summary statistics.
Parameters
bundle(ExOKF.Bundle.t()) — loaded OKF bundle
Returns
%{nodes: non_neg_integer(), edges: non_neg_integer(), backend: module()}
Examples
iex> bundle = ExOKF.TestSupport.sample_bundle()
iex> stats = ExOKF.Graph.stats(bundle)
iex> {stats.nodes, stats.backend}
{3, ExOKF.Graph.Adjacency}