public void WeaklyConnectedCondensation()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         RunWeaklyConnectedCondensationAndCheck(graph);
     }
 }
 public void TopologicalSort()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         RunTopologicalSortAndCheck(graph);
     }
 }
 public void StronglyConnectedComponents()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         RunStronglyConnectedComponentsAndCheck(graph);
     }
 }
 public void RandomWalk()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         RunRandomWalkAndCheck(graph);
     }
 }
 public void AllVerticesAugmentor()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         RunAugmentationAndCheck(graph);
     }
 }
Exemplo n.º 6
0
        public void ToDirectedGraphML_WithFormat()
        {
            foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
            {
                int           formattedNodes = 0;
                int           formattedEdges = 0;
                DirectedGraph directedGraph  = graph.ToDirectedGraphML(
                    graph.GetVertexIdentity(),
                    graph.GetEdgeIdentity(),
                    (vertex, node) =>
                {
                    Assert.IsNotNull(vertex);
                    Assert.IsNotNull(node);
                    ++formattedNodes;
                },
                    (edge, link) =>
                {
                    Assert.IsNotNull(edge);
                    Assert.IsNotNull(link);
                    ++formattedEdges;
                });
                Assert.IsNotNull(graph);

                Assert.AreEqual(graph.VertexCount, formattedNodes);
                Assert.AreEqual(graph.EdgeCount, formattedEdges);
                AssertGraphContentEquivalent(graph, directedGraph);
            }
        }
Exemplo n.º 7
0
        public void ToDirectedGraphML_WithFormat()
        {
            foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
            {
                int formattedNodes = 0;
                int formattedEdges = 0;
                // ReSharper disable ParameterOnlyUsedForPreconditionCheck.Local
                DirectedGraph directedGraph = graph.ToDirectedGraphML(
                    graph.GetVertexIdentity(),
                    graph.GetEdgeIdentity(),
                    (vertex, node) =>
                {
                    Assert.IsNotNull(vertex);
                    Assert.IsNotNull(node);
                    ++formattedNodes;
                },
                    (edge, link) =>
                {
                    Assert.IsNotNull(edge);
                    Assert.IsNotNull(link);
                    ++formattedEdges;
                });
                // ReSharper restore ParameterOnlyUsedForPreconditionCheck.Local
                Assert.IsNotNull(graph);

                Assert.AreEqual(graph.VertexCount, formattedNodes);
                Assert.AreEqual(graph.EdgeCount, formattedEdges);
                AssertGraphContentEquivalent(graph, directedGraph);
            }
        }
Exemplo n.º 8
0
        public void ToDirectedGraphML()
        {
            foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
            {
                DirectedGraph directedGraph = graph.ToDirectedGraphML();
                Assert.IsNotNull(graph);

                AssertGraphContentEquivalent(graph, directedGraph);
            }
        }
Exemplo n.º 9
0
 public void OutDegreeSumEqualsEdgeCount()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         OutDegreeSumEqualsEdgeCount(graph);
     }
     foreach (BidirectionalGraph <string, Edge <string> > graph in TestGraphFactory.GetBidirectionalGraphs_All())
     {
         OutDegreeSumEqualsEdgeCount(graph);
     }
 }
Exemplo n.º 10
0
        public void ToDirectedGraphML_WithIdentities()
        {
            foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
            {
                int           i             = 0;
                DirectedGraph directedGraph = graph.ToDirectedGraphML(
                    vertex => vertex,
                    edge => (++i).ToString());
                Assert.IsNotNull(graph);

                AssertGraphContentEquivalent(graph, directedGraph);
            }
        }
Exemplo n.º 11
0
        public void ToDirectedGraphML_WithColors()
        {
            var random = new QuikGraph.Utils.CryptoRandom(123456);

            foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
            {
                Dictionary <string, GraphColor> vertexColors = graph.Vertices.ToDictionary(
                    vertex => vertex,
                    vertex => (GraphColor)random.Next(0, 3));

                DirectedGraph directedGraph = graph.ToDirectedGraphML(
                    vertex =>
                {
                    Assert.IsNotNull(vertex);
                    return(vertexColors[vertex]);
                });
                Assert.IsNotNull(graph);

                AssertGraphContentEquivalent(graph, directedGraph);

                foreach (DirectedGraphNode node in directedGraph.Nodes)
                {
                    Assert.AreEqual(
                        ColorToStringColor(vertexColors[node.Id]),
                        node.Background);
                }
            }

            #region Local function

            string ColorToStringColor(GraphColor color)
            {
                switch (color)
                {
                case GraphColor.Black:
                    return("Black");

                case GraphColor.Gray:
                    return("LightGray");

                case GraphColor.White:
                    return("White");

                default:
                    Assert.Fail("Unknown color.");
                    return(string.Empty);
                }
            }

            #endregion
        }
 public void ConversionToArrayGraph()
 {
     foreach (AdjacencyGraph <string, Edge <string> > graph in TestGraphFactory.GetAdjacencyGraphs_All())
     {
         AssertSameProperties(graph);
     }
     foreach (BidirectionalGraph <string, Edge <string> > graph in TestGraphFactory.GetBidirectionalGraphs_All())
     {
         AssertSameProperties(graph);
     }
     foreach (UndirectedGraph <string, Edge <string> > graph in TestGraphFactory.GetUndirectedGraphs_All())
     {
         AssertSameProperties(graph);
     }
 }