RdfGraph constructor
Creates an immutable RDF graph from a list of triples
The constructor makes a defensive copy of the provided triples list to ensure immutability. The graph can be initialized with an empty list to create an empty graph.
Parameters:
triples
The initial collection of triples to include in the graph. Defaults to an empty collection.enableIndexing
Whether to enable lazy indexing for query optimization. When enabled, an internal index is created lazily on first query to improve performance for subsequent pattern matching operations. The index is only built when actually needed, so enabling this option has no immediate memory cost. Defaults to true.
Example:
// Empty graph with indexing enabled (default)
final emptyGraph = RdfGraph();
// Graph with initial triples and indexing disabled
final graph = RdfGraph(triples: myTriples, enableIndexing: false);
Implementation
RdfGraph({Iterable<Triple> triples = const [], bool enableIndexing = true})
: _triples = List.unmodifiable(triples),
indexingEnabled = enableIndexing;