Paradigm.Graph.Diff (paradigm v0.3.0)

Summary

Functions

Asserts that two graphs are equal by computing their diff and throwing an error if there are any differences.

Computes the difference between two graphs, capturing missing nodes, added nodes, and changed attributes.

Functions

assert_equal(old_graph, new_graph)

@spec assert_equal(Paradigm.Graph.t(), Paradigm.Graph.t()) :: :ok

Asserts that two graphs are equal by computing their diff and throwing an error if there are any differences.

Raises an error if the graphs differ, otherwise returns :ok.

diff(old_graph, new_graph)

@spec diff(Paradigm.Graph.t(), Paradigm.Graph.t()) :: %{
  added: [Paradigm.Graph.node_id()],
  removed: [Paradigm.Graph.node_id()],
  changed: %{required(Paradigm.Graph.node_id()) => map()}
}

Computes the difference between two graphs, capturing missing nodes, added nodes, and changed attributes.

Returns a map with:

  • :added - list of node_ids present in new_graph but not in old_graph
  • :removed - list of node_ids present in old_graph but not in new_graph
  • :changed - map of node_id => %{class: %{old: class, new: class}, data: %{key => %{old: value, new: value}}} for nodes with different attributes or class