Pure RDF.Graph algebra: add/delete/cleanup/intersection over triple sets.
Ported from Gno's Gno.Changeset.Helper graph-algebra helpers
(~/gno/lib/gno/changeset/helper.ex), stripped of everything that requires a
live, queryable triple store (Gno's EffectiveChangeset.Query SPARQL-CONSTRUCT
diff-against-store algorithm). AshR2RML has no such store to diff against --
Ontop is virtual OBDA over Postgres, never a materialized graph -- so this
module only keeps the store-independent, purely functional half of that
pattern: combining and subtracting RDF.Graph.t() values already held in
memory (e.g. two successive renders of the same mapping's R2RML Turtle, or two
successive AshR2RML.OBDA.InMemory.materialize/3 snapshots).
No network, no file I/O, no external process -- every function here is a pure
transformation over RDF.Graph structs already in hand.
Summary
Functions
True if graph and other describe exactly the same set of statements
(order- and blank-node-labeling-independent for ground triples).
Merges addition into graph, returning a new graph with every statement of
both. Equivalent to RDF.Graph.add/2 but named to match the changeset-algebra
vocabulary (add as a changeset action, not just a graph operation).
Drops every subject description that has no statements left, so a graph never
carries empty RDF.Description entries after a deletion.
Removes every statement of removal from graph, returning a new graph.
Subjects left with no statements after removal are dropped entirely (see
graph_cleanup/1), so the result never carries orphaned empty descriptions.
Returns the statements present in both left and right, as a new graph.
Useful for detecting the effective overlap between two mapping-render
snapshots before deciding whether a regenerated .ttl file actually changed.
Functions
@spec equivalent?(RDF.Graph.t(), RDF.Graph.t()) :: boolean()
True if graph and other describe exactly the same set of statements
(order- and blank-node-labeling-independent for ground triples).
@spec graph_add(RDF.Graph.t(), RDF.Graph.t() | nil) :: RDF.Graph.t()
Merges addition into graph, returning a new graph with every statement of
both. Equivalent to RDF.Graph.add/2 but named to match the changeset-algebra
vocabulary (add as a changeset action, not just a graph operation).
@spec graph_cleanup(RDF.Graph.t()) :: RDF.Graph.t()
Drops every subject description that has no statements left, so a graph never
carries empty RDF.Description entries after a deletion.
@spec graph_delete(RDF.Graph.t(), RDF.Graph.t() | nil) :: RDF.Graph.t()
Removes every statement of removal from graph, returning a new graph.
Subjects left with no statements after removal are dropped entirely (see
graph_cleanup/1), so the result never carries orphaned empty descriptions.
@spec graph_intersection(RDF.Graph.t(), RDF.Graph.t()) :: RDF.Graph.t()
Returns the statements present in both left and right, as a new graph.
Useful for detecting the effective overlap between two mapping-render
snapshots before deciding whether a regenerated .ttl file actually changed.