当前位置: 首页>>代码示例>>C#>>正文


C# AdjacencyGraph.DeserializeFromGraphML方法代码示例

本文整理汇总了C#中AdjacencyGraph.DeserializeFromGraphML方法的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph.DeserializeFromGraphML方法的具体用法?C# AdjacencyGraph.DeserializeFromGraphML怎么用?C# AdjacencyGraph.DeserializeFromGraphML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdjacencyGraph的用法示例。


在下文中一共展示了AdjacencyGraph.DeserializeFromGraphML方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadGraph

 private static AdjacencyGraph<Node, Edge<Node>> ReadGraph(string filename)
 {
     var graph = new AdjacencyGraph<Node, Edge<Node>>();
     using (var reader = XmlReader.Create(filename))
     {
         graph.DeserializeFromGraphML(reader,
                 id => new Node(),
                 (source, target, id) => new Edge<Node>(source, target));
     }
     return graph;
 }
开发者ID:yksz,项目名称:samples,代码行数:11,代码来源:GraphForm.cs

示例2: LoadGraph

        public static AdjacencyGraph<string, Edge<string>> LoadGraph(string path)
        {
            // Save the graph
            using (var xReader = XmlReader.Create(File.OpenText(path)))
            {
                var graph = new AdjacencyGraph<string, Edge<string>>();
                graph.DeserializeFromGraphML<string, Edge<string>, AdjacencyGraph<string, Edge<string>>>(xReader,
                    id => id,
                    (source, target, id) => new Edge<string>(source, target));

                return graph;
            }
        }
开发者ID:igormoochnick,项目名称:AssemblyDependencyGraphVisualizer,代码行数:13,代码来源:AssemblyGraph.cs

示例3: LoadGraph

 public static AdjacencyGraph<string, Edge<string>> LoadGraph(string graphmlFile)
 {
     TestConsole.WriteLine(graphmlFile);
     var g = new AdjacencyGraph<string, Edge<string>>();
     using (var reader = new StreamReader(graphmlFile))
     {
         g.DeserializeFromGraphML(
             reader,
             id => id,
             (source, target, id) => new Edge<string>(source, target)
             );
     }
     return g;
 }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:14,代码来源:GraphMLSerializerTest.cs

示例4: DeserializeFromGraphMLNorth

        public void DeserializeFromGraphMLNorth()
        {
            foreach (var graphmlFile in TestGraphFactory.GetFileNames())
            {
                Console.Write(graphmlFile);
                var g = new AdjacencyGraph<string, Edge<string>>();
                using (var reader = new StreamReader(graphmlFile))
                {
                    g.DeserializeFromGraphML(
                        reader,
                        id => id,
                        (source, target, id) => new Edge<string>(source, target)
                        );
                }
                Console.Write(": {0} vertices, {1} edges", g.VertexCount, g.EdgeCount);

                var vertices = new Dictionary<string, string>();
                foreach(var v in g.Vertices)
                    vertices.Add(v, v);

                // check all nodes are loaded
                var settings = new XmlReaderSettings();
                settings.XmlResolver = new GraphMLXmlResolver();
                settings.DtdProcessing = DtdProcessing.Ignore;
                settings.ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None;
                using(var xreader = XmlReader.Create(graphmlFile, settings))
                {
                    var doc = new XPathDocument(xreader);
                    foreach (XPathNavigator node in doc.CreateNavigator().Select("/graphml/graph/node"))
                    {
                        string id = node.GetAttribute("id", "");
                        Assert.IsTrue(vertices.ContainsKey(id));
                    }
                    TestConsole.Write(", vertices ok");

                    // check all edges are loaded
                    foreach (XPathNavigator node in doc.CreateNavigator().Select("/graphml/graph/edge"))
                    {
                        string source = node.GetAttribute("source", "");
                        string target = node.GetAttribute("target", "");
                        Assert.IsTrue(g.ContainsEdge(vertices[source], vertices[target]));
                    }
                    TestConsole.Write(", edges ok");
                }
                TestConsole.WriteLine();
            }
        }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:47,代码来源:GraphMLSerializerTest.cs


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