Plexus.Graph (Plexus v0.1.0)

Copy Markdown View Source

Per-run lock-free node and typed-edge graph.

Nodes live in an ETS :set. Edges live in an ETS :ordered_set and are stored in both outgoing and incoming directions, avoiding children-list read/modify/write races and the global graph GenServer from the original scaffold.

Summary

Types

edge_type()

@type edge_type() :: atom()

Functions

add_edge(run_id, type, from, to, weight \\ 1.0, provenance \\ nil)

@spec add_edge(term(), edge_type(), term(), term(), number(), term()) :: :ok

attach_child(run_id, parent_id, child_id)

@spec attach_child(term(), term(), term()) :: :ok

by_class(run_id, class)

@spec by_class(term(), term()) :: [{term(), map()}]

children(run_id, actor_id)

@spec children(term(), term()) :: [term()]

count(run_id)

@spec count(term()) :: non_neg_integer()

delete_node(run_id, actor_id)

@spec delete_node(term(), term()) :: :ok

delete_subtree(run_id, actor_id)

@spec delete_subtree(term(), term()) :: :ok

get(run_id, actor_id)

@spec get(term(), term()) :: map() | nil

incoming(run_id, actor_id, type \\ :all)

@spec incoming(term(), term(), edge_type() | :all) :: [map()]

nodes(run_id)

@spec nodes(term()) :: [{term(), map()}]

outgoing(run_id, actor_id, type \\ :all)

@spec outgoing(term(), term(), edge_type() | :all) :: [map()]

prune(run_id, actor_id)

@spec prune(term(), term()) :: :ok

Prune through the runtime so evaluations/processes are stopped before metadata is removed.

put(run_id, actor_id, attrs)

@spec put(term(), term(), keyword() | map()) :: :ok

subtree(run_id, actor_id)

@spec subtree(term(), term()) :: [term()]

update(run_id, actor_id, fun)

@spec update(term(), term(), (map() -> map())) :: :ok | {:error, :not_found}