Ejemplo n.º 1
0
        public void SortCyclicPUT_NEW1(AdjacencyGraph g, bool rndConstructor, bool allowParallelEdges, int numberOfVertices, bool toNull)
        {
            g = AdjacencyGraphFactory.CreateAcyclicGraph1(allowParallelEdges, numberOfVertices, toNull);
            TopologicalSortAlgorithm topo;
            List <IVertex>           list = null;

            if (g != null && g.VerticesCount > 0)
            {
                list = new List <IVertex>();
                foreach (IVertex v in g.Vertices)
                {
                    IVertex a = g.AddVertex();
                    list.Add(v);
                }
                g = createCycle(g);
            }
            if (rndConstructor)
            {
                topo = new TopologicalSortAlgorithm(g, list);
            }
            else
            {
                topo = new TopologicalSortAlgorithm(g);
            }

            topo.Compute();
            for (int j = 0; j < topo.SortedVertices.Count; ++j)
            {
                PexObserve.ValueForViewing <IVertex>("Sorted Vertex", (IVertex)topo.SortedVertices[j]);
            }
        }
        public void AddEdgeTargetNotFound04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 5);
            ((GenericMutableGraphTestNEW)this).AddEdgeTargetNotFound(adjacencyGraph);
        }
Ejemplo n.º 3
0
        public void RemoveEdgeNotFound07()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 16);
            ((GenericMutableGraphTestNEW)this).RemoveEdgeNotFound(adjacencyGraph);
        }
Ejemplo n.º 4
0
        public void RemoveEdgeNotFound06()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 5);
            this.RemoveEdgeNotFound(adjacencyGraph);
        }
Ejemplo n.º 5
0
        public void Simple()
        {
            IVertexListGraph <string, Edge <string> > g = new AdjacencyGraphFactory().Simple();
            StronglyConnectedComponentsAlgorithm <string, Edge <String> > strong = new StronglyConnectedComponentsAlgorithm <string, Edge <String> >(g);

            strong.Compute();
            checkStrong(strong);
        }
        public void GraphWithSelfEdgesPUT08()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            this.GraphWithSelfEdgesPUT(adjacencyGraph, 2);
        }
        public void AddEdgeTargetNotFound04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, true, 9);
            this.AddEdgeTargetNotFound(adjacencyGraph);
        }
Ejemplo n.º 8
0
        public void AddEdgeSourceNotFound03()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 26);
            this.AddEdgeSourceNotFound(adjacencyGraph);
        }
        public void AddRemoveVertexNotFound04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 16);
            this.AddRemoveVertexNotFound(adjacencyGraph);
        }
Ejemplo n.º 10
0
        public void SortCyclicPUT_NEW08()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 16);
            this.SortCyclicPUT_NEW(adjacencyGraph, (IVertex[])null, false);
        }
        public void AddEdgeTargetNotFound03()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 4);
            this.AddEdgeTargetNotFound(adjacencyGraph);
        }
        public void AddRemoveVertexNotFound05()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            this.AddRemoveVertexNotFound(adjacencyGraph);
        }
        public void GraphWithSelfEdgesPUT09()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 16);
            this.GraphWithSelfEdgesPUT(adjacencyGraph, 2);
        }
Ejemplo n.º 14
0
        public void RemoveEdgeNotFound08()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 16);
            this.RemoveEdgeNotFound(adjacencyGraph);
        }
Ejemplo n.º 15
0
        public void AddRemoveVertexNotFound05()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 5);
            ((GenericMutableGraphTestNEW)this).AddRemoveVertexNotFound(adjacencyGraph);
        }
Ejemplo n.º 16
0
        public void SortCyclicPUT_NEW20()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, true, 0);
            IVertex[] iVertexs = new IVertex[1];
            this.SortCyclicPUT_NEW(adjacencyGraph, iVertexs, false);
        }
Ejemplo n.º 17
0
        public void SortCyclicPUT_NEW18()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 16);
            IVertex[] iVertexs = new IVertex[3];
            this.SortCyclicPUT_NEW(adjacencyGraph, iVertexs, true);
        }
        public void Loop()
        {
            IVertexListGraph<string,Edge<string>> g = new AdjacencyGraphFactory().Loop();
            StronglyConnectedComponentsAlgorithm<string, Edge<String>> strong = new StronglyConnectedComponentsAlgorithm<string, Edge<String>>(g);
            strong.Compute();
            Assert.AreEqual(1, strong.ComponentCount);

            checkStrong(strong);
        }
Ejemplo n.º 19
0
        public void GraphWithSelfEdgesPUT06()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            IPexChoiceRecorder choices = PexChoose.NewTest();

            this.GraphWithSelfEdgesPUT(adjacencyGraph, 2, false);
        }
Ejemplo n.º 20
0
        public void Loop()
        {
            IVertexListGraph <string, Edge <string> > g = new AdjacencyGraphFactory().Loop();
            StronglyConnectedComponentsAlgorithm <string, Edge <String> > strong = new StronglyConnectedComponentsAlgorithm <string, Edge <String> >(g);

            strong.Compute();
            Assert.AreEqual(1, strong.ComponentCount);

            checkStrong(strong);
        }
Ejemplo n.º 21
0
        public void IterationPUT02()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 16);
            ((GenericVertexListGraphTest)this).IterationPUT(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
        public void AddRemoveVertex01()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 0);
            this.AddRemoveVertex(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 23
0
        public void ClearVertexTargetSource04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            this.ClearVertexTargetSource(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 24
0
        public void TestOutDegree03()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            ((GenericAdjacencyGraphTest)this).TestOutDegree(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 25
0
        public void ClearVertexSourceTarget04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            ((GenericMutableGraphTestNEW)this).ClearVertexSourceTarget(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 26
0
        public void AddRemoveVertex02()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph(s0, false, 16);
            ((GenericMutableGraphTestNEW)this).AddRemoveVertex(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
        public void RemoveOutEdgeIf02()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            ((GenericMutableAdjacencyGraphTest)this).RemoveOutEdgeIf(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 28
0
        public void IterationPUT03()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph(s0, false, 0);
            this.IterationPUT(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 29
0
        public void GraphWithoutSelfEdges()
        {
            AdjacencyGraph <string, Edge <string> > g = new AdjacencyGraphFactory().FileDependency();

            foreach (string v in g.Vertices)
            {
                parents[v] = v;
            }

            // compute
            dfs.Compute();
            CheckDfs();
        }
        public void RemoveOutEdgeIf01()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateAcyclicGraph
                                 (s0, PexSafeHelpers.ByteToBoolean((byte)4), 49);
            ((GenericMutableAdjacencyGraphTest)this).RemoveOutEdgeIf(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
Ejemplo n.º 31
0
        public void RemoveOutEdgeIf04()
        {
            AdjacencyGraph        adjacencyGraph;
            VertexAndEdgeProvider s0 = new VertexAndEdgeProvider();

            adjacencyGraph = AdjacencyGraphFactory.CreateCyclicGraph
                                 (s0, PexSafeHelpers.ByteToBoolean((byte)2), 16);
            this.RemoveOutEdgeIf(adjacencyGraph);
            PexAssert.IsNotNull((object)adjacencyGraph);
            PexAssert.AreEqual <bool>(true, adjacencyGraph.IsDirected);
            PexAssert.IsNotNull(adjacencyGraph.Provider);
            PexAssert.IsNotNull(adjacencyGraph.Edges);
        }
        public void FileDependency()
        {
            IVertexListGraph<string, Edge<string>> g = new AdjacencyGraphFactory().FileDependency();
            StronglyConnectedComponentsAlgorithm<string, Edge<String>> strong = new StronglyConnectedComponentsAlgorithm<string, Edge<String>>(g);

            strong.Compute();
            checkStrong(strong);
        }
        public void GraphWithoutSelfEdges()
        {
            AdjacencyGraph<string, Edge<string>> g = new AdjacencyGraphFactory().FileDependency();

            foreach (string v in g.Vertices)
                parents[v] = v;

            // compute
            dfs.Compute();
            CheckDfs();
        }
        public void RegularLattice()
        {
            IVertexListGraph<string, Edge<string>> g = new AdjacencyGraphFactory().RegularLattice10x10();
            StronglyConnectedComponentsAlgorithm<string, Edge<String>> strong = new StronglyConnectedComponentsAlgorithm<string, Edge<String>>(g);

            strong.Compute();
            checkStrong(strong);
        }
 public void SortCyclic()
 {
     IVertexAndEdgeListGraph<string, Edge<string>> g = new AdjacencyGraphFactory().Loop();
     this.Sort(g);
 }