without method

RdfGraph without(
  1. RdfGraph other
)

Creates a new graph by removing all triples from another graph

This method performs graph subtraction - it removes all triples present in the other graph from this graph. Since RdfGraph is immutable, this returns a new instance with the remaining triples.

This operation is useful for:

  • Removing a specific subset of knowledge from a graph
  • Computing the difference between two graphs
  • Undoing the effects of a previous merge operation

Parameters:

  • other The graph whose triples should be removed from this graph

Returns: A new graph containing all triples from this graph except those that also exist in the other graph. If the graphs share no common triples, returns a new graph identical to the original.

Example:

// Remove all personal information from a combined dataset
final publicGraph = fullGraph.without(personalInfoGraph);

// Compute the difference between two versions of a graph
final changesOnly = newVersion.without(oldVersion);

Implementation

RdfGraph without(RdfGraph other) {
  return withoutTriples(other._triples);
}