本文整理汇总了C#中IGraph类的典型用法代码示例。如果您正苦于以下问题:C# IGraph类的具体用法?C# IGraph怎么用?C# IGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IGraph类属于命名空间,在下文中一共展示了IGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpansionDataset
public ExpansionDataset(IGraph expansionDescription, INode datasetSubj)
: base(expansionDescription, datasetSubj)
{
//Check for aat:ignoreDataset
IEnumerable<Triple> ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:ignoreDataset"));
Triple t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Literal)
{
ILiteralNode l = (ILiteralNode)t.Object;
if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeBoolean))
{
this._ignore = Boolean.Parse(l.Value);
}
}
}
//Find URI Discovery Endpoints
ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:uriDiscoveryEndpoint"));
foreach (Triple endpoint in ts)
{
if (endpoint.Object.NodeType == NodeType.Uri)
{
this._discoveryEndpoints.Add(((IUriNode)endpoint.Object).Uri);
}
}
}
示例2: QuickRemove
public QuickRemove(ToolStripMenuItem menu, IGraph g, INode objNode, String file)
{
this._menu = menu;
this._g = g;
this._objNode = objNode;
this._file = file;
}
示例3: DehydrateValue
public override string DehydrateValue(object obj, IGraph uow)
{
if (obj == null)
return null;
return base.Decorated.DehydrateValue(obj, uow);
}
示例4: Save
public void Save(IGraph g, TextWriter output)
{
JToken flattened = MakeExpandedForm(g);
output.Write(flattened.ToString(Formatting.None, new JsonConverter[0]));
output.Flush();
}
示例5: CanHandle
public bool CanHandle(object obj, IGraph uow)
{
if (obj == null)
return false;
return obj is IHasHydrationMap;
}
示例6: RdfXmlWriterContext
/// <summary>
/// Creates a new RDF/XML Writer Context
/// </summary>
/// <param name="g">Graph</param>
/// <param name="output">Output destination</param>
public RdfXmlWriterContext(IGraph g, TextWriter output)
{
this._g = g;
this._output = output;
this._writer = XmlWriter.Create(this._output, this.GetSettings());
this._nsmapper.Import(this._g.NamespaceMap);
}
示例7: GetLists
private static IDictionary<INode, List<INode>> GetLists(IGraph graph)
{
INode first = graph.CreateUriNode(new Uri(First));
INode rest = graph.CreateUriNode(new Uri(Rest));
INode nil = graph.CreateUriNode(new Uri(Nil));
IDictionary<INode, List<INode>> lists = new Dictionary<INode, List<INode>>();
IEnumerable<Triple> ends = graph.GetTriplesWithPredicateObject(rest, nil);
foreach (Triple end in ends)
{
List<INode> list = new List<INode>();
Triple iterator = graph.GetTriplesWithSubjectPredicate(end.Subject, first).First();
INode head = iterator.Subject;
while (true)
{
list.Add(iterator.Object);
IEnumerable<Triple> restTriples = graph.GetTriplesWithPredicateObject(rest, iterator.Subject);
if (!restTriples.Any())
{
break;
}
iterator = graph.GetTriplesWithSubjectPredicate(restTriples.First().Subject, first).First();
head = iterator.Subject;
}
list.Reverse();
lists.Add(head, list);
}
return lists;
}
示例8: Arc
public Arc(IGraph graph, object head, object tail)
{
this.Graph = graph;
((IEdge)this).Vertices = new IVertex[2];
this.Head = this.Graph[head];
this.Tail = this.Graph[tail];
}
示例9: ReplaceResourceUris
public static IGraph ReplaceResourceUris(IGraph original, IDictionary<string, Uri> replacements)
{
IGraph modified = new Graph();
foreach (Triple triple in original.Triples)
{
Uri subjectUri;
if (!replacements.TryGetValue(triple.Subject.ToString(), out subjectUri))
{
subjectUri = ((IUriNode)triple.Subject).Uri;
}
INode subjectNode = modified.CreateUriNode(subjectUri);
INode predicateNode = triple.Predicate.CopyNode(modified);
INode objectNode;
if (triple.Object is IUriNode)
{
Uri objectUri;
if (!replacements.TryGetValue(triple.Object.ToString(), out objectUri))
{
objectUri = ((IUriNode)triple.Object).Uri;
}
objectNode = modified.CreateUriNode(objectUri);
}
else
{
objectNode = triple.Object.CopyNode(modified);
}
modified.Assert(subjectNode, predicateNode, objectNode);
}
return modified;
}
示例10: BaseProtocolHandlerConfiguration
/// <summary>
/// Creates a new Protocol Handler Configuration
/// </summary>
/// <param name="context">HTTP Context</param>
/// <param name="g">Configuration Graph</param>
/// <param name="objNode">Object Node</param>
public BaseProtocolHandlerConfiguration(HttpContext context, IGraph g, INode objNode)
: base(context, g, objNode)
{
//Then get the Protocol Processor to be used
ISparqlHttpProtocolProcessor processor;
INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyProtocolProcessor));
if (procNode == null) throw new DotNetRdfConfigurationException("Unable to load Protocol Handler Configuration as the RDF configuration file does not specify a dnr:protocolProcessor property for the Handler");
Object temp = ConfigurationLoader.LoadObject(g, procNode);
if (temp is ISparqlHttpProtocolProcessor)
{
processor = (ISparqlHttpProtocolProcessor)temp;
}
else
{
throw new DotNetRdfConfigurationException("Unable to load Protocol Handler Configuration as the RDF configuration file specifies a value for the Handlers dnr:protocolProcessor property which cannot be loaded as an object which implements the ISparqlHttpProtocolProcessor interface");
}
this._processor = processor;
//Get the Service Description Graph
INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServiceDescription));
if (descripNode != null)
{
Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
if (descrip is IGraph)
{
this._serviceDescription = (IGraph)descrip;
}
else
{
throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
}
}
}
示例11: Write
/// <summary>
/// Writes the Graph to a String and returns the output in your chosen concrete RDF Syntax
/// </summary>
/// <param name="g">Graph to save</param>
/// <param name="writer">Writer to use to generate the concrete RDF Syntax</param>
/// <returns></returns>
/// <remarks>
/// Since the API allows for any <see cref="TextWriter">TextWriter</see> to be passed to the <see cref="IRdfWriter.Save">Save()</see> method of a <see cref="IRdfWriter">IRdfWriter</see> you can just pass in a <see cref="StringWriter">StringWriter</see> to the Save() method to get the output as a String. This method simply provides a wrapper to doing just that.
/// </remarks>
public static String Write(IGraph g, IRdfWriter writer)
{
System.IO.StringWriter sw = new System.IO.StringWriter();
writer.Save(g, sw);
return sw.ToString();
}
示例12: FormatGraphHeader
/// <summary>
/// Formats a Graph Header by creating an <strong><rdf:RDF></strong> element and adding namespace definitions
/// </summary>
/// <param name="g">Graph</param>
/// <returns></returns>
public string FormatGraphHeader(IGraph g)
{
this._mapper = new QNameOutputMapper(g.NamespaceMap);
StringBuilder output = new StringBuilder();
output.Append(this.GetGraphHeaderBase());
foreach (String prefix in g.NamespaceMap.Prefixes)
{
if (!prefix.Equals("rdf"))
{
if (prefix.Equals(String.Empty))
{
output.Append(" xmlns=\"" + WriterHelper.EncodeForXml(g.NamespaceMap.GetNamespaceUri(prefix).ToString()) + "\"");
}
else
{
output.Append(" xmlns:" + prefix + "=\"" + WriterHelper.EncodeForXml(g.NamespaceMap.GetNamespaceUri(prefix).ToString()) + "\"");
}
}
}
if (g.BaseUri != null)
{
output.Append(" xml:base=\"" + WriterHelper.EncodeForXml(g.BaseUri.ToString()) + "\"");
}
output.Append(">");
return output.ToString();
}
示例13: DehydrateValue
public string DehydrateValue(object obj, IGraph uow)
{
Condition.Requires(obj).IsNotNull();
var name = obj.GetType().Name;
var val = obj.ToString();
return LengthEncoder.LengthEncodeList(name, val);
}
示例14: CanHandle
public bool CanHandle(object obj, IGraph uow)
{
if (obj == null)
return false;
return PrimitivesUtil.IsSystemPrimitive(obj);
}
示例15: FindNegativeWeightCycle
/// <summary>
/// The Find-Negative-Weight-Cycle() procedure to determine whether a graph has a negative-weight cycle,
/// and how to construct one if it does.
/// </summary>
/// <param name="graph">A directed graph containing a set V of n vertices and a set E of m directed edges with arbitrary weights on which
/// the BellmanFord() procedure has already been run.</param>
/// <returns>
/// Either a list of vertices in a negative-weight cycle, in order,
/// or an empty list if the graph has no negative-weight cycles.
/// </returns>
public List<int> FindNegativeWeightCycle(IGraph directedGraph)
{
foreach (var u in directedGraph.Vertices)
foreach (var v in directedGraph[u])
if (Shortest[u] + directedGraph.Weight(u, v) < Shortest[v])
{
int vTemp = v;
bool[] visited = new bool[directedGraph.N]; // Initialized by default to false //
int x = v;
while (!visited[x])
{
visited[x] = true;
x = (int)Graph.Predecessors[x];
}
vTemp = (int)Graph.Predecessors[x];
var cycle = new List<int>() { x };
while (vTemp != x)
{
cycle.Insert(0, vTemp);
vTemp = (int)Graph.Predecessors[vTemp];
}
return cycle;
}
/**
* No negative edges, return empty list .. (P.104).
*/
return new List<int>();
}