Paradigm.Graph.Canonical (paradigm v0.3.0)

Converts graphs into canonical Elixir structs, and vice versa.

Summary

Functions

Converts an Elixir struct into graph nodes using the Graph protocol.

Converts a graph node into its canonical Elixir struct representation.

Functions

struct_to_graph(graph, struct_data, node_id)

@spec struct_to_graph(Paradigm.Graph.t(), struct(), Paradigm.Graph.node_id()) ::
  Paradigm.Graph.t()

Converts an Elixir struct into graph nodes using the Graph protocol.

  • Uses the struct's module name as the class_id
  • Converts nested structs into references
  • Inserts all nodes into the graph

to_struct(graph, node_id)

@spec to_struct(Paradigm.Graph.t(), Paradigm.Graph.node_id()) :: struct() | nil

Converts a graph node into its canonical Elixir struct representation.

  • The struct name is derived from the node's class
  • All %Paradigm.Graph.Node.Ref{} values are expanded in place
  • Cycle detection prevents infinite recursion