本文整理汇总了C#中Graph.HasSubGraph方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.HasSubGraph方法的具体用法?C# Graph.HasSubGraph怎么用?C# Graph.HasSubGraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.HasSubGraph方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StorageDydraSaveToDefaultGraph
public void StorageDydraSaveToDefaultGraph()
{
try
{
Options.HttpDebugging = true;
Graph orig = new Graph();
orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
orig.BaseUri = null;
DydraConnector dydra = this.GetConnection();
dydra.SaveGraph(orig);
Graph g = new Graph();
dydra.LoadGraph(g, (Uri)null);
if (orig.Triples.Count == g.Triples.Count)
{
Assert.AreEqual(orig, g, "Graphs should be equal");
}
else
{
Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph");
}
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
finally
{
Options.HttpDebugging = false;
}
}
示例2: StorageSesameDeleteTriples
public void StorageSesameDeleteTriples()
{
try
{
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/SesameTest");
SesameHttpProtocolConnector sesame = new SesameHttpProtocolConnector("http://nottm-virtual.ecs.soton.ac.uk:8080/openrdf-sesame/", "unit-test");
sesame.SaveGraph(g);
Console.WriteLine("Graph before deletion");
TestTools.ShowGraph(g);
//Delete all Triples about the Ford Fiesta
sesame.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));
Object results = sesame.Query("ASK WHERE { <http://example.org/vehicles/FordFiesta> ?p ?o }");
if (results is SparqlResultSet)
{
Assert.IsFalse(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
}
Graph h = new Graph();
sesame.LoadGraph(h, g.BaseUri);
Console.WriteLine("Graph after deletion");
TestTools.ShowGraph(h);
Assert.IsFalse(h.IsEmpty, "Graph should not be completely empty");
Assert.IsTrue(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
Assert.IsFalse(g.Equals(h), "Graph retrieved should not be equal to original Graph");
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
}
示例3: StorageAllegroGraphDeleteTriples
public void StorageAllegroGraphDeleteTriples()
{
try
{
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/AllegroGraphTest");
AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875", "test", "unit-test");
agraph.SaveGraph(g);
Console.WriteLine("Graph before deletion");
TestTools.ShowGraph(g);
//Delete all Triples about the Ford Fiesta
agraph.UpdateGraph(g.BaseUri, null, g.GetTriplesWithSubject(new Uri("http://example.org/vehicles/FordFiesta")));
Graph h = new Graph();
agraph.LoadGraph(h, g.BaseUri);
Console.WriteLine("Graph after deletion");
TestTools.ShowGraph(h);
Assert.IsFalse(h.IsEmpty, "Graph should not be completely empty");
Assert.IsTrue(g.HasSubGraph(h), "Graph retrieved with missing Triples should be a sub-graph of the original Graph");
Assert.IsFalse(g.Equals(h), "Graph retrieved should not be equal to original Graph");
Object results = agraph.Query("ASK WHERE { GRAPH <http://example.org/AllegroGraphTest> { <http://example.org/vehicles/FordFiesta> ?p ?o } }");
if (results is SparqlResultSet)
{
Assert.IsFalse(((SparqlResultSet)results).Result, "There should no longer be any triples about the Ford Fiesta present");
}
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
}
示例4: SparqlDatasetDefaultGraphManagementWithUpdate5
public void SparqlDatasetDefaultGraphManagementWithUpdate5()
{
TripleStore store = new TripleStore();
Graph g = new Graph();
g.BaseUri = new Uri("http://example.org/graph");
store.Add(g);
Graph h = new Graph();
h.BaseUri = new Uri("http://example.org/someOtherGraph");
store.Add(h);
InMemoryDataset dataset = new InMemoryDataset(store, h.BaseUri);
LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset);
SparqlUpdateParser parser = new SparqlUpdateParser();
SparqlUpdateCommandSet cmds = parser.ParseFromString("LOAD <http://www.dotnetrdf.org/configuration#>; WITH <http://example.org/graph> INSERT { ?s a ?type } USING <http://example.org/someOtherGraph> WHERE { ?s a ?type }; DELETE WHERE { ?s a ?type }");
processor.ProcessCommandSet(cmds);
Assert.IsFalse(g.IsEmpty, "First Graph should not be empty as should have been filled by the INSERT command");
Assert.IsFalse(h.IsEmpty, "Second Graph should not be empty as should not have been filled by the LOAD command");
Assert.IsFalse(h.HasSubGraph(g), "First Graph should not be a subgraph of the Second Graph as the DELETE should have eliminated the subgraph relationship");
}
示例5: StorageStardogSaveToDefaultGraph
public void StorageStardogSaveToDefaultGraph()
{
try
{
//Options.UseBomForUtf8 = false;
StardogConnector stardog = this.GetConnection();
Graph g = new Graph();
g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
g.BaseUri = null;
stardog.SaveGraph(g);
Graph h = new Graph();
stardog.LoadGraph(h, (Uri)null);
if (g.Triples.Count == h.Triples.Count)
{
Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph");
}
else
{
Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph");
}
}
finally
{
//Options.UseBomForUtf8 = true;
}
}
示例6: StorageStardogDeleteNamedGraph
public void StorageStardogDeleteNamedGraph()
{
try
{
//Options.UseBomForUtf8 = false;
StardogConnector stardog = this.GetConnection();
Graph g = new Graph();
g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
g.BaseUri = new Uri("http://example.org/tempGraph");
stardog.SaveGraph(g);
Graph h = new Graph();
stardog.LoadGraph(h, new Uri("http://example.org/tempGraph"));
if (g.Triples.Count == h.Triples.Count)
{
Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph");
}
else
{
Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph");
}
stardog.DeleteGraph("http://example.org/tempGraph");
Graph i = new Graph();
stardog.LoadGraph(i, new Uri("http://example.org/tempGraph"));
Assert.IsTrue(i.IsEmpty, "Retrieved Graph should be empty since it has been deleted");
}
finally
{
//Options.UseBomForUtf8 = true;
}
}
示例7: StorageStardogUpdateNamedGraphAddTriples
public void StorageStardogUpdateNamedGraphAddTriples()
{
try
{
//Options.UseBomForUtf8 = false;
StardogConnector stardog = this.GetConnection();
Graph g = new Graph();
g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
g.BaseUri = new Uri("http://example.org/addGraph");
INode rdfType = g.CreateUriNode(new Uri(VDS.RDF.Parsing.RdfSpecsHelper.RdfType));
Graph types = new Graph();
types.Assert(g.GetTriplesWithPredicate(rdfType));
g.Retract(g.GetTriplesWithPredicate(rdfType));
//Save the Graph without the rdf:type triples
stardog.SaveGraph(g);
//Then add back in the rdf:type triples
stardog.UpdateGraph(g.BaseUri, types.Triples, null);
Graph h = new Graph();
stardog.LoadGraph(h, new Uri("http://example.org/addGraph"));
if (g.Triples.Count == h.Triples.Count)
{
Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph");
}
else
{
Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph");
}
Assert.IsTrue(h.GetTriplesWithPredicate(rdfType).Any(), "Retrieved Graph should not contain any rdf:type Triples");
}
finally
{
//Options.UseBomForUtf8 = true;
}
}
示例8: SparqlUpdateAddCommand
public void SparqlUpdateAddCommand()
{
IGraph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/source");
IGraph h = new Graph();
FileLoader.Load(h, "Turtle.ttl");
h.BaseUri = new Uri("http://example.org/destination");
TripleStore store = new TripleStore();
store.Add(g);
store.Add(h);
Assert.AreNotEqual(g, h, "Graphs should not be equal");
SparqlUpdateParser parser = new SparqlUpdateParser();
SparqlUpdateCommandSet commands = parser.ParseFromString("ADD GRAPH <http://example.org/source> TO GRAPH <http://example.org/destination>");
LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(store);
processor.ProcessCommandSet(commands);
g = store.Graph(new Uri("http://example.org/source"));
h = store.Graph(new Uri("http://example.org/destination"));
Assert.IsFalse(g.IsEmpty, "Source Graph should not be empty");
Assert.IsFalse(h.IsEmpty, "Destination Graph should not be empty");
Assert.IsTrue(h.HasSubGraph(g), "Destination Graph should have Source Graph as a subgraph");
}