Ejemplo n.º 1
0
 public void CondensateAndCheckDAG(
     [PexAssumeNotNull] IVertexAndEdgeListGraph <string, Edge <string> > g)
 {
     this.algo = new CondensationGraphAlgorithm <string, Edge <string>, AdjacencyGraph <string, Edge <string> > >(g);
     algo.Compute();
     CheckDAG(g);
 }
Ejemplo n.º 2
0
 public void CondensateAndCheckComponentCount(IVertexAndEdgeListGraph <string, Edge <string> > g)
 {
     this.algo = new CondensationGraphAlgorithm <string, Edge <string>, AdjacencyGraph <string, Edge <string> > >(g);
     this.algo.StronglyConnected = false;
     algo.Compute();
     CheckComponentCount(g);
 }
        private void CheckComponentCount <TVertex, TEdge>(IVertexAndEdgeListGraph <TVertex, TEdge> g,
                                                          CondensationGraphAlgorithm <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> > algo)
            where TEdge : IEdge <TVertex>
        {
            // check number of vertices = number of storngly connected components
            int components = g.WeaklyConnectedComponents <TVertex, TEdge>(new Dictionary <TVertex, int>());

            Assert.AreEqual(components, algo.CondensedGraph.VertexCount, "ComponentCount does not match");
        }
        public void WeaklyConnectedCondensate <TVertex, TEdge>(IVertexAndEdgeListGraph <TVertex, TEdge> g)
            where TEdge : IEdge <TVertex>
        {
            var algo = new CondensationGraphAlgorithm <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> >(g);

            algo.StronglyConnected = false;
            algo.Compute();
            CheckVertexCount(g, algo);
            CheckEdgeCount(g, algo);
            CheckComponentCount(g, algo);
        }
        private void CheckVertexCount <TVertex, TEdge>(IVertexAndEdgeListGraph <TVertex, TEdge> g,
                                                       CondensationGraphAlgorithm <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> > algo)
            where TEdge : IEdge <TVertex>
        {
            int count = 0;

            foreach (var vertices in algo.CondensedGraph.Vertices)
            {
                count += vertices.VertexCount;
            }
            Assert.AreEqual(g.VertexCount, count, "VertexCount does not match");
        }
Ejemplo n.º 6
0
        private void CheckEdgeCount <TVertex, TEdge>(IVertexAndEdgeListGraph <TVertex, TEdge> g,
                                                     CondensationGraphAlgorithm <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> > algo)
            where TEdge : IEdge <TVertex>
        {
            // check edge count
            int count = 0;

            foreach (var edges in algo.CondensedGraph.Edges)
            {
                count += edges.Edges.Count;
            }
            foreach (var vertices in algo.CondensedGraph.Vertices)
            {
                count += vertices.EdgeCount;
            }
            Assert.Equal(g.EdgeCount, count);
        }