• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IGraph的典型用法代码示例。如果您正苦于以下问题:C# IGraph类的具体用法?C# IGraph怎么用?C# IGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IGraph类属于命名空间,在下文中一共展示了IGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
                }
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:28,代码来源:ExpansionDataset.cs


示例2: QuickRemove

 public QuickRemove(ToolStripMenuItem menu, IGraph g, INode objNode, String file)
 {
     this._menu = menu;
     this._g = g;
     this._objNode = objNode;
     this._file = file;
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:7,代码来源:QuickConnect.cs


示例3: DehydrateValue

        public override string DehydrateValue(object obj, IGraph uow)
        {
            if (obj == null)
                return null;

            return base.Decorated.DehydrateValue(obj, uow);
        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:7,代码来源:NullCheckDecoration.cs


示例4: Save

        public void Save(IGraph g, TextWriter output)
        {
            JToken flattened = MakeExpandedForm(g);

            output.Write(flattened.ToString(Formatting.None, new JsonConverter[0]));
            output.Flush();
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:JsonLdWriter.cs


示例5: CanHandle

        public bool CanHandle(object obj, IGraph uow)
        {
            if (obj == null)
                return false;

            return obj is IHasHydrationMap;
        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:7,代码来源:HasHydrationMapValueManager.cs


示例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);
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:12,代码来源:RdfXmlWriterContext.cs


示例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;
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:32,代码来源:JsonLdWriter.cs


示例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];
 }
开发者ID:THROYAN,项目名称:GraphEditor,代码行数:7,代码来源:Arc.cs


示例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;
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:34,代码来源:GraphSplitting.cs


示例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");
                }
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:39,代码来源:BaseProtocolHandlerConfiguration.cs


示例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();
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:16,代码来源:StringWriter.cs


示例12: FormatGraphHeader

 /// <summary>
 /// Formats a Graph Header by creating an <strong>&lt;rdf:RDF&gt;</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();
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:31,代码来源:RdfXmlFormatter.cs


示例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);
 }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:7,代码来源:PrimitiveValueManager.cs


示例14: CanHandle

        public bool CanHandle(object obj, IGraph uow)
        {
            if (obj == null)
                return false;

            return PrimitivesUtil.IsSystemPrimitive(obj);
        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:7,代码来源:PrimitiveValueManager.cs


示例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>();
        }
开发者ID:ioab,项目名称:AU,代码行数:41,代码来源:BellmanFord.cs


示例16: GetPackageRegistrationUri

 public static Uri GetPackageRegistrationUri(IGraph graph)
 {
     return ((IUriNode)graph.GetTriplesWithPredicateObject(
         graph.CreateUriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")),
         graph.CreateUriNode(new Uri("http://schema.nuget.org/schema#PackageRegistration")))
         .First().Subject).Uri;
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:GraphSplitting.cs


示例17: Connects

 /// <summary>
 /// 
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="g"></param>
 /// <returns></returns>
 public static ConnectsEdgePredicate Connects(
     IVertex source,
     IVertex target,
     IGraph g)
 {
     return new ConnectsEdgePredicate(source,target,g);
 }
开发者ID:BackupTheBerlios,项目名称:mbunit-svn,代码行数:14,代码来源:Preds.cs


示例18: CanHandle

        public override bool CanHandle(object obj, IGraph uow)
        {
            if (obj == null)
                return false;

            return obj.IsMarkedSerializable();
        }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:7,代码来源:SerializableValueManager.cs


示例19: CheckCompressionRoundTrip

        private void CheckCompressionRoundTrip(IGraph g)
        {
            foreach (KeyValuePair<IRdfWriter, IRdfReader> kvp in this._compressers)
            {

                IRdfWriter writer = kvp.Key;
                if (writer is ICompressingWriter)
                {
                    ((ICompressingWriter)writer).CompressionLevel = WriterCompressionLevel.High;
                }
                if (writer is IHighSpeedWriter)
                {
                    ((IHighSpeedWriter)writer).HighSpeedModePermitted = false;
                }
                System.IO.StringWriter strWriter = new System.IO.StringWriter();
                writer.Save(g, strWriter);

                Console.WriteLine("Compressed Output using " + kvp.Key.GetType().Name);
                Console.WriteLine(strWriter.ToString());
                Console.WriteLine();

                Graph h = new Graph();
                StringParser.Parse(h, strWriter.ToString(), kvp.Value);

                Assert.AreEqual(g, h, "Graphs should be equal after round trip to and from serialization using " + kvp.Key.GetType().Name);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:CollectionCompressionTests.cs


示例20: MinCut

                /// <summary>
                /// Returns the lightest set of edges that would divide the graph in two components should they be removed.
                /// </summary>
                /// <param name="graph">The flow graph to calculate the minimum cut of.</param>
                /// <param name="source">The source of the flow.</param>
                /// <param name="sink">The sink of the flow.</param>
                /// <returns>A list containing the edges that make up the minimum cut.</returns>
                public static List<IFlowGraphEdge> MinCut(IGraph<IFlowGraphEdge> graph, uint source, uint sink)
                {
                    Dictionary<uint, Dictionary<uint, FlowEdge>> flowGraph = BuildFlowGraph(graph);
                    MaxFlow(flowGraph, source, sink);

                    List<IFlowGraphEdge> cut = new List<IFlowGraphEdge>();
                    HashSet<uint> reachable = new HashSet<uint>();
                    Queue<uint> open = new Queue<uint>();

                    open.Enqueue(source);
                    reachable.Add(source);
                    while (open.Count > 0)
                    {
                        uint i = open.Dequeue();
                        foreach (uint j in flowGraph[i].Keys)
                            if (!reachable.Contains(j) && flowGraph[i][j].Residual > 0)
                            {
                                open.Enqueue(j);
                                reachable.Add(j);
                            }
                    }

                    foreach (uint i in reachable)
                    {
                        foreach (uint j in flowGraph[i].Keys)
                            if (!reachable.Contains(j))
                                cut.Add(flowGraph[i][j].Original);
                    }

                    return cut;
                }
开发者ID:jlvermeulen,项目名称:algorithms-and-data-structures,代码行数:38,代码来源:MaxFlowMinCut.cs



注:本文中的IGraph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IGraphBuilder类代码示例发布时间:2022-05-24
下一篇:
C# IGrainState类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap