Interface IGraph
Interface for RDF Graphs.
Inherited Members
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public interface IGraph : INodeFactory, IDisposable, ITripleIndex, IEquatable<IGraph>
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Properties
| Improve this Doc View SourceAllNodes
Gets the unique Subject, Predicate and Object nodes of the asserted triples in the Graph.
Declaration
IEnumerable<INode> AllNodes { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><INode> |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
AllQuotedNodes
Gets the unique subject, predicate and object nodes of the quoted triples in the graph.
Declaration
IEnumerable<INode> AllQuotedNodes { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><INode> |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
IsEmpty
Gets whether a Graph is Empty.
Declaration
bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Name
Gets the name of the graph.
Declaration
IRefNode Name { get; }
Property Value
| Type | Description |
|---|---|
| IRefNode |
Remarks
The graph name May be NULL for an unnamed (default) graph.
Nodes
Gets the unique Subject and Object nodes of the Graph.
Declaration
IEnumerable<INode> Nodes { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><INode> |
Remarks
This property returns only nodes that appear in the Subject or Object position in asserted triples. To retrieve a list of all INode instances in a graph including those in Predicate position in a triple, use the AllNodes property.
QuotedNodes
Gets the unique subject and object nodes of the quoted triples in the graph.
Declaration
IEnumerable<INode> QuotedNodes { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><INode> |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
QuotedTriples
Gets the quoted triples in the graph.
Declaration
IEnumerable<Triple> QuotedTriples { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><Triple> |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Triples
Gets the Triple Collection for the Graph.
Declaration
BaseTripleCollection Triples { get; }
Property Value
| Type | Description |
|---|---|
| BaseTripleCollection |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Methods
| Improve this Doc View SourceAssert(IEnumerable<Triple>)
Asserts an Enumerable of Triples in the Graph.
Declaration
bool Assert(IEnumerable<Triple> ts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><Triple> | ts | An Enumerable of Triples. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Assert(Triple)
Asserts a Triple in the Graph.
Declaration
bool Assert(Triple t)
Parameters
| Type | Name | Description |
|---|---|---|
| Triple | t | A Triple. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Clear()
Retracts all Triples from the Graph.
Declaration
void Clear()
Remarks
The Graph should raise the ClearRequested event at the start of the Clear operation and abort the operation if the operation is cancelled by an event handler. On completing the Clear the Cleared event should be raised.
ContainsQuotedTriple(Triple)
Gets whether a given triple is quoted in this graph.
Declaration
bool ContainsQuotedTriple(Triple t)
Parameters
| Type | Name | Description |
|---|---|---|
| Triple | t | Triple to test. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the triple is quoted in this graph, false otherwise. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
ContainsTriple(Triple)
Gets whether a given triple is asserted in this Graph.
Declaration
bool ContainsTriple(Triple t)
Parameters
| Type | Name | Description |
|---|---|---|
| Triple | t | Triple to test. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the triple is asserted in this graph, false otherwise. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Difference(IGraph)
Calculates the difference between this Graph and the given Graph.
Declaration
GraphDiffReport Difference(IGraph g)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph. |
Returns
| Type | Description |
|---|---|
| GraphDiffReport |
Remarks
Produces a report which shows the changes that must be made to this Graph to produce the given Graph.
Equals(IGraph, out Dictionary<INode, INode>)
Checks whether a Graph is equal to another Graph and if so returns the mapping of Blank Nodes.
Declaration
bool Equals(IGraph g, out Dictionary<INode, INode> mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to compare with. |
| System.Collections.Generic.Dictionary<TKey, TValue><INode, INode> | mapping | Mapping of Blank Nodes. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetBlankNode(string)
Selects the Blank Node with the given ID if it exists in the Graph, returns null otherwise.
Declaration
IBlankNode GetBlankNode(string nodeId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | nodeId | Node ID. |
Returns
| Type | Description |
|---|---|
| IBlankNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetLiteralNode(string, string)
Selects the Literal Node with the given Value and Language if it exists in the Graph, returns null otherwise.
Declaration
ILiteralNode GetLiteralNode(string literal, string langspec)
Parameters
| Type | Name | Description |
|---|---|---|
| string | literal | Value of the Literal. |
| string | langspec | Language Specifier of the Literal. |
Returns
| Type | Description |
|---|---|
| ILiteralNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetLiteralNode(string, Uri)
Selects the Literal Node with the given Value and DataType if it exists in the Graph, returns otherwise.
Declaration
ILiteralNode GetLiteralNode(string literal, Uri datatype)
Parameters
| Type | Name | Description |
|---|---|---|
| string | literal | Value of the Literal. |
| System.Uri | datatype | Data Type of the Literal. |
Returns
| Type | Description |
|---|---|
| ILiteralNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetLiteralNode(string)
Selects the Literal Node with the given Value if it exists in the Graph, returns null otherwise.
Declaration
ILiteralNode GetLiteralNode(string literal)
Parameters
| Type | Name | Description |
|---|---|---|
| string | literal | Value of the Literal. |
Returns
| Type | Description |
|---|---|
| ILiteralNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetTripleNode(Triple)
Selects the Triple Node with the given Triple value if it exists in the graph.
Declaration
ITripleNode GetTripleNode(Triple triple)
Parameters
| Type | Name | Description |
|---|---|---|
| Triple | triple | Triple. |
Returns
| Type | Description |
|---|---|
| ITripleNode | The triple node if it exists in the graph or else null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetUriNode(string)
Selects the Uri Node with the given QName if it exists in the Graph, returns null otherwise.
Declaration
IUriNode GetUriNode(string qname)
Parameters
| Type | Name | Description |
|---|---|---|
| string | qname | QName. |
Returns
| Type | Description |
|---|---|
| IUriNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
GetUriNode(Uri)
Selects the Uri Node with the given Uri if it exists in the Graph, returns null otherwise.
Declaration
IUriNode GetUriNode(Uri uri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Uri | uri | Uri. |
Returns
| Type | Description |
|---|---|
| IUriNode | The Node if it exists in the Graph or null. |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
HasSubGraph(IGraph, out Dictionary<INode, INode>)
Checks whether this Graph has the given Graph as a sub-graph.
Declaration
bool HasSubGraph(IGraph g, out Dictionary<INode, INode> mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph. |
| System.Collections.Generic.Dictionary<TKey, TValue><INode, INode> | mapping | Mapping of Blank Nodes. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
HasSubGraph(IGraph)
Checks whether this Graph has the given Graph as a sub-graph.
Declaration
bool HasSubGraph(IGraph g)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
IsSubGraphOf(IGraph, out Dictionary<INode, INode>)
Checks whether this Graph is a sub-graph of the given Graph.
Declaration
bool IsSubGraphOf(IGraph g, out Dictionary<INode, INode> mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph. |
| System.Collections.Generic.Dictionary<TKey, TValue><INode, INode> | mapping | Mapping of Blank Nodes. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
IsSubGraphOf(IGraph)
Checks whether this Graph is a sub-graph of the given Graph.
Declaration
bool IsSubGraphOf(IGraph g)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Merge(IGraph, bool)
Merges the given Graph into this Graph.
Declaration
void Merge(IGraph g, bool keepOriginalGraphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to merge. |
| System.Boolean | keepOriginalGraphUri | Indicates that the Merge should preserve the Graph URIs of Nodes. |
Remarks
The Graph should raise the MergeRequested event at the start of the Merge operation and abort the operation if the operation is cancelled by an event handler. On completing the Merge the Merged event should be raised.
Merge(IGraph)
Merges the given Graph into this Graph.
Declaration
void Merge(IGraph g)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to merge. |
Remarks
The Graph should raise the MergeRequested event at the start of the Merge operation and abort the operation if the operation is cancelled by an event handler. On completing the Merge the Merged event should be raised.
Retract(IEnumerable<Triple>)
Retracts an Enumerable of Triples from the Graph.
Declaration
bool Retract(IEnumerable<Triple> ts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><Triple> | ts | Enumerable of Triples. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Retract(Triple)
Retracts a Triple from the Graph.
Declaration
bool Retract(Triple t)
Parameters
| Type | Name | Description |
|---|---|---|
| Triple | t | A Triple. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Unstar()
Converts an graph containing quoted triples into to a graph with no quoted triples by applying the unstar operation described in https://w3c.github.io/rdf-star/cg-spec/2021-12-17.html#mapping.
Declaration
void Unstar()
Remarks
The unstar operation modifies the graph in-place by calls to Assert(Triple) an Retract(Triple).
Events
| Improve this Doc View SourceChanged
Event which is raised when the Graph contents change
Declaration
event GraphEventHandler Changed
Event Type
| Type | Description |
|---|---|
| GraphEventHandler |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Cleared
Event which is raised after the Graph is cleared of its contents
Declaration
event GraphEventHandler Cleared
Event Type
| Type | Description |
|---|---|
| GraphEventHandler |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
ClearRequested
Event which is raised just before the Graph is cleared of its contents
Declaration
event CancellableGraphEventHandler ClearRequested
Event Type
| Type | Description |
|---|---|
| CancellableGraphEventHandler |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
Merged
Event which is raised when a Merge operation is completed on the Graph
Declaration
event GraphEventHandler Merged
Event Type
| Type | Description |
|---|---|
| GraphEventHandler |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
MergeRequested
Event which is raised just before a Merge operation begins on the Graph
Declaration
event CancellableGraphEventHandler MergeRequested
Event Type
| Type | Description |
|---|---|
| CancellableGraphEventHandler |
Remarks
Most implementations will probably want to inherit from the abstract class BaseGraph since it contains reference implementations of various algorithms (Graph Equality/Graph Difference/Sub-Graph testing etc) which will save considerable work in implementation and ensure consistent behaviour of some methods across implementations.
TripleAsserted
Event which is raised when a Triple is asserted in the Graph
Declaration
event TripleEventHandler TripleAsserted
Event Type
| Type | Description |
|---|---|
| TripleEventHandler |
Remarks
Whenever this event is raised the Changed event should also be raised
TripleRetracted
Event which is raised when a Triple is retracted from the Graph
Declaration
event TripleEventHandler TripleRetracted
Event Type
| Type | Description |
|---|---|
| TripleEventHandler |
Remarks
Whenever this event is raised the Changed event should also be raised