Class Graph
Class for representing RDF Graphs.
Inheritance
Inherited Members
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public class Graph : BaseGraph, IGraph, INodeFactory, IDisposable, ITripleIndex, IEquatable<IGraph>, IEquatable<Graph>
Constructors
| Improve this Doc View SourceGraph()
Creates a new instance of a graph.
Declaration
public Graph()
Graph(bool)
Creates a new instance of a Graph with an optionally empty Namespace Map.
Declaration
public Graph(bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | emptyNamespaceMap | Whether the Namespace Map should be empty. |
Graph(Uri, bool)
Creates a new instance of a named graph with an optionally empty namespace map.
Declaration
public Graph(Uri name, bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | name | The graph name. |
System.Boolean | emptyNamespaceMap | Whether the namespace map should be empty. |
Graph(Uri, BaseTripleCollection, bool)
Creates a new named graph using the given triple collection and an optionally empty namespace map.
Declaration
public Graph(Uri name, BaseTripleCollection tripleCollection, bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | name | The graph name. |
BaseTripleCollection | tripleCollection | The triple collection that will be the content of the new graph. |
System.Boolean | emptyNamespaceMap | Whether the namespace map should be empty. |
Graph(Uri, BaseTripleCollection)
Creates a new instance of a named using the given triple collection.
Declaration
public Graph(Uri name, BaseTripleCollection tripleCollection)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | name | The graph name. |
BaseTripleCollection | tripleCollection | The triple collection that will be the content of the new graph. |
Graph(Uri)
Creates a new instance of a graph with the specified URI as the graph name.
Declaration
public Graph(Uri name)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | name | The graph name as a URI. |
Graph(BaseTripleCollection, bool)
Creates a new instance of a Graph using the given Triple Collection and an optionally empty Namespace Map.
Declaration
public Graph(BaseTripleCollection tripleCollection, bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
BaseTripleCollection | tripleCollection | Triple Collection. |
System.Boolean | emptyNamespaceMap | Whether the Namespace Map should be empty. |
Graph(BaseTripleCollection)
Creates a new instance of a Graph using the given Triple Collection.
Declaration
public Graph(BaseTripleCollection tripleCollection)
Parameters
Type | Name | Description |
---|---|---|
BaseTripleCollection | tripleCollection | Triple Collection. |
Graph(IRefNode, bool)
Creates a new instance of a named graph with an optionally empty namespace map.
Declaration
public Graph(IRefNode name, bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | name | The graph name. |
System.Boolean | emptyNamespaceMap | Whether the namespace map should be empty. |
Graph(IRefNode, BaseTripleCollection, bool)
Creates a new named graph using the given triple collection and an optionally empty namespace map.
Declaration
public Graph(IRefNode name, BaseTripleCollection tripleCollection, bool emptyNamespaceMap)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | name | The graph name. |
BaseTripleCollection | tripleCollection | The triple collection that will be the content of the new graph. |
System.Boolean | emptyNamespaceMap | Whether the namespace map should be empty. |
Graph(IRefNode, BaseTripleCollection)
Creates a new instance of a named using the given triple collection.
Declaration
public Graph(IRefNode name, BaseTripleCollection tripleCollection)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | name | The graph name. |
BaseTripleCollection | tripleCollection | The triple collection that will be the content of the new graph. |
Graph(IRefNode, INodeFactory, IUriFactory, BaseTripleCollection, bool)
Creates a new instance of a Graph.
Declaration
public Graph(IRefNode name, INodeFactory nodeFactory = null, IUriFactory uriFactory = null, BaseTripleCollection tripleCollection = null, bool emptyNamespaceMap = false)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | name | The name to assign to the graph. If null, the graph is unnamed. |
INodeFactory | nodeFactory | The factory to use when constructing nodes in this graph. If null, defaults to a new NodeFactory instance using the same UriFactory instance as this graph. |
IUriFactory | uriFactory | The factory to use when constructing URIs in this graph. If null, defaults to the root UriFactory. |
BaseTripleCollection | tripleCollection | The initial content of the graph. If null, the graph will initially be empty. |
System.Boolean | emptyNamespaceMap | Whether to initialise the graph with an empty namespace map. If false, the namespace map will contain default declarations for the RDF, RDFS and XSD namespaces. |
Methods
| Improve this Doc View SourceAssert(IEnumerable<Triple>)
Asserts a List of Triples in the graph.
Declaration
public override bool Assert(IEnumerable<Triple> ts)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T><Triple> | ts | List of Triples in the form of an IEnumerable. |
Returns
Type | Description |
---|---|
System.Boolean | True if at least one Triple in |
Overrides
| Improve this Doc View SourceAssert(Triple)
Asserts a Triple in the Graph.
Declaration
public override bool Assert(Triple t)
Parameters
Type | Name | Description |
---|---|---|
Triple | t | The Triple to add to the Graph. |
Returns
Type | Description |
---|---|
System.Boolean | True if the triple was added to the graph, false if it was not (because it already exists in the graph). |
Overrides
| Improve this Doc View SourceEquals(Graph)
Implements equality testing between Graph instances.
Declaration
public bool Equals(Graph other)
Parameters
Type | Name | Description |
---|---|---|
Graph | other |
Returns
Type | Description |
---|---|
System.Boolean |
GetBlankNode(string)
Returns the Blank Node with the given Identifier.
Declaration
public override IBlankNode GetBlankNode(string nodeId)
Parameters
Type | Name | Description |
---|---|---|
string | nodeId | The Identifier of the Blank Node to select. |
Returns
Type | Description |
---|---|
IBlankNode | Either the Blank Node or null if no Node with the given Identifier exists. |
Overrides
| Improve this Doc View SourceGetLiteralNode(string, string)
Returns the LiteralNode with the given Value in the given Language if it exists.
Declaration
public override ILiteralNode GetLiteralNode(string literal, string langSpec)
Parameters
Type | Name | Description |
---|---|---|
string | literal | The literal value of the Node to select. |
string | langSpec | The Language Specifier for the Node to select. |
Returns
Type | Description |
---|---|
ILiteralNode | Either the LiteralNode Or null if no Node with the given Value and Language Specifier exists. |
Overrides
| Improve this Doc View SourceGetLiteralNode(string, Uri)
Returns the LiteralNode with the given Value and given Data Type if it exists.
Declaration
public override ILiteralNode GetLiteralNode(string literal, Uri datatype)
Parameters
Type | Name | Description |
---|---|---|
string | literal | The literal value of the Node to select. |
System.Uri | datatype | The Uri for the Data Type of the Literal to select. |
Returns
Type | Description |
---|---|
ILiteralNode | Either the LiteralNode Or null if no Node with the given Value and Data Type exists. |
Overrides
| Improve this Doc View SourceGetLiteralNode(string)
Returns the LiteralNode with the given Value if it exists.
Declaration
public override ILiteralNode GetLiteralNode(string literal)
Parameters
Type | Name | Description |
---|---|---|
string | literal | The literal value of the Node to select. |
Returns
Type | Description |
---|---|
ILiteralNode | Either the LiteralNode Or null if no Node with the given Value exists. |
Overrides
Remarks
The LiteralNode in the Graph must have no Language or DataType set.
GetQuoted(INode)
Selects all quoted triples which contain the given Node.
Declaration
public override IEnumerable<Triple> GetQuoted(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithObject(INode)
Selects all quoted triples where the Object is a given Node.
Declaration
public override IEnumerable<Triple> GetQuotedWithObject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithPredicate(INode)
Selects all quoted triples where the Predicate is a given Node.
Declaration
public override IEnumerable<Triple> GetQuotedWithPredicate(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithPredicateObject(INode, INode)
Selects all quoted triples with the given Predicate and Object.
Declaration
public override IEnumerable<Triple> GetQuotedWithPredicateObject(INode pred, INode obj)
Parameters
Type | Name | Description |
---|---|---|
INode | pred | Predicate. |
INode | obj | Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithSubject(INode)
Selects all quoted triples where the Subject is a given Node.
Declaration
public override IEnumerable<Triple> GetQuotedWithSubject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithSubjectObject(INode, INode)
Selects all quoted triples with the given Subject and Object.
Declaration
public override IEnumerable<Triple> GetQuotedWithSubjectObject(INode subj, INode obj)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject. |
INode | obj | Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetQuotedWithSubjectPredicate(INode, INode)
Selects all quoted triples with the given Subject and Predicate.
Declaration
public override IEnumerable<Triple> GetQuotedWithSubjectPredicate(INode subj, INode pred)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject. |
INode | pred | Predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetTripleNode(Triple)
Selects the Triple Node with the given Triple value if it exists in the graph.
Declaration
public override 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. |
Overrides
| Improve this Doc View SourceGetTriples(Uri)
Gets all the Triples involving the given Uri.
Declaration
public override IEnumerable<Triple> GetTriples(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The Uri to find Triples involving. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriples(INode)
Gets all the Triples involving the given Node.
Declaration
public override IEnumerable<Triple> GetTriples(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | The Node to find Triples involving. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriplesWithObject(Uri)
Gets all the Triples with the given Uri as the Object.
Declaration
public override IEnumerable<Triple> GetTriplesWithObject(Uri u)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | u | The Uri to find Triples with it as the Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriplesWithObject(INode)
Gets all the Triples with the given Node as the Object.
Declaration
public override IEnumerable<Triple> GetTriplesWithObject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | The Node to find Triples with it as the Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetTriplesWithPredicate(Uri)
Gets all the Triples with the given Uri as the Predicate.
Declaration
public override IEnumerable<Triple> GetTriplesWithPredicate(Uri u)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | u | The Uri to find Triples with it as the Predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriplesWithPredicate(INode)
Gets all the Triples with the given Node as the Predicate.
Declaration
public override IEnumerable<Triple> GetTriplesWithPredicate(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | The Node to find Triples with it as the Predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetTriplesWithPredicateObject(INode, INode)
Selects all Triples with the given Predicate and Object.
Declaration
public override IEnumerable<Triple> GetTriplesWithPredicateObject(INode pred, INode obj)
Parameters
Type | Name | Description |
---|---|---|
INode | pred | Predicate. |
INode | obj | Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetTriplesWithSubject(Uri)
Gets all the Triples with the given Uri as the Subject.
Declaration
public override IEnumerable<Triple> GetTriplesWithSubject(Uri u)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | u | The Uri to find Triples with it as the Subject. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriplesWithSubject(INode)
Gets all the Triples with the given Node as the Subject.
Declaration
public override IEnumerable<Triple> GetTriplesWithSubject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | The Node to find Triples with it as the Subject. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> | Zero/More Triples. |
Overrides
| Improve this Doc View SourceGetTriplesWithSubjectObject(INode, INode)
Selects all Triples with the given Subject and Object.
Declaration
public override IEnumerable<Triple> GetTriplesWithSubjectObject(INode subj, INode obj)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject. |
INode | obj | Object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetTriplesWithSubjectPredicate(INode, INode)
Selects all Triples with the given Subject and Predicate.
Declaration
public override IEnumerable<Triple> GetTriplesWithSubjectPredicate(INode subj, INode pred)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject. |
INode | pred | Predicate. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Triple> |
Overrides
| Improve this Doc View SourceGetUriNode(string)
Returns the UriNode with the given QName if it exists.
Declaration
public override IUriNode GetUriNode(string qName)
Parameters
Type | Name | Description |
---|---|---|
string | qName | The QName of the Node to select. |
Returns
Type | Description |
---|---|
IUriNode |
Overrides
| Improve this Doc View SourceGetUriNode(Uri)
Returns the UriNode with the given Uri if it exists.
Declaration
public override IUriNode GetUriNode(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The Uri of the Node to select. |
Returns
Type | Description |
---|---|
IUriNode | Either the UriNode Or null if no Node with the given Uri exists. |
Overrides
| Improve this Doc View SourceRetract(IEnumerable<Triple>)
Retracts a enumeration of Triples from the graph.
Declaration
public override bool Retract(IEnumerable<Triple> ts)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T><Triple> | ts | Enumeration of Triples to retract. |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
| Improve this Doc View SourceRetract(Triple)
Retracts a Triple from the Graph.
Declaration
public override bool Retract(Triple t)
Parameters
Type | Name | Description |
---|---|---|
Triple | t | Triple to Retract. |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Remarks
Current implementation may have some defunct Nodes left in the Graph as only the Triple is retracted.