private void AssertSourceAndTargetInGraph()
 {
     // In case the root or target vertex is not in the graph then there is no path found
     if (!_graph.ContainsVertex(_sourceVertex) || !_graph.ContainsVertex(_targetVertex))
     {
         throw new NoPathFoundException();
     }
 }
Esempio n. 2
0
 private static void VerifyCount <TVertex, TEdge>(
     IMutableVertexAndEdgeListGraph <TVertex, TEdge> g,
     AllVerticesGraphAugmentorAlgorithm <TVertex, TEdge> augmentor,
     int vertexCount)
     where TEdge : IEdge <TVertex>
 {
     Assert.Equal(vertexCount + 2, g.VertexCount);
     Assert.True(g.ContainsVertex(augmentor.SuperSource));
     Assert.True(g.ContainsVertex(augmentor.SuperSink));
 }
 private static void VerifyCount <TVertex, TEdge>(
     [NotNull] IMutableVertexAndEdgeListGraph <TVertex, TEdge> graph,
     // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
     [NotNull] AllVerticesGraphAugmentorAlgorithm <TVertex, TEdge> augmentor,
     int vertexCount)
     where TEdge : IEdge <TVertex>
 {
     Assert.AreEqual(vertexCount + 2, graph.VertexCount);
     Assert.IsTrue(graph.ContainsVertex(augmentor.SuperSource));
     Assert.IsTrue(graph.ContainsVertex(augmentor.SuperSink));
 }
Esempio n. 4
0
        public void AddSuperSourceAndSink(IMutableVertexAndEdgeListGraph <string, Edge <string> > g)
        {
            SetUp(g);
            int vertexCount = g.VertexCount;

            this.augmentor.Compute();

            Assert.AreEqual(vertexCount + 2, g.VertexCount);
            Assert.IsTrue(g.ContainsVertex(this.augmentor.SuperSource));
            Assert.IsTrue(g.ContainsVertex(this.augmentor.SuperSink));
        }
        public void AddAndRemoveVertex(IMutableVertexAndEdgeListGraph <int, Edge <int> > g, int v)
        {
            int vertexCount = g.VertexCount;

            g.AddVertex(v);
            Assert.Equal(vertexCount + 1, g.VertexCount);
            Assert.True(g.ContainsVertex(v));
            g.RemoveVertex(v);
            Assert.Equal(vertexCount, g.VertexCount);
            Assert.False(g.ContainsVertex(v));
            //VerifyCounts(g);
        }
        public void AddVertexOnly(IMutableVertexAndEdgeListGraph <string, Edge <string> > g, string v)
        {
            int vertexCount = g.VertexCount;

            g.AddVertex(v);
            Assert.Equal(vertexCount + 1, g.VertexCount);
            Assert.True(g.ContainsVertex(v));
            VerifyCounts(g);
        }
        public void AddVertexAddEdgesAndRemoveSourceVertex(IMutableVertexAndEdgeListGraph <string, Edge <string> > g, string v1, string v2)
        {
            int vertexCount = g.VertexCount;
            int edgeCount   = g.EdgeCount;

            g.AddVertex(v1);
            g.AddVertex(v2);
            Assert.Equal(vertexCount + 2, g.VertexCount);
            Assert.True(g.ContainsVertex(v1));
            Assert.True(g.ContainsVertex(v2));

            g.AddEdge(new Edge <string>(v1, v2));
            Assert.Equal(edgeCount + 1, g.EdgeCount);

            g.RemoveVertex(v1);
            Assert.Equal(vertexCount + 1, g.VertexCount);
            Assert.Equal(edgeCount, g.EdgeCount);
            Assert.True(g.ContainsVertex(v2));
            Assert.False(g.ContainsVertex(v1));
            VerifyCounts(g);
        }
        public void AddVertexAddEdgesAndRemoveTargetVertex([PexAssumeNotNull] IMutableVertexAndEdgeListGraph <string, Edge <string> > g, string v1, string v2)
        {
            int vertexCount = g.VertexCount;
            int edgeCount   = g.EdgeCount;

            g.AddVertex(v1);
            g.AddVertex(v2);
            Assert.AreEqual(vertexCount + 2, g.VertexCount);
            Assert.IsTrue(g.ContainsVertex(v1));
            Assert.IsTrue(g.ContainsVertex(v2));

            g.AddEdge(new Edge <string>(v1, v2));
            Assert.AreEqual(edgeCount + 1, g.EdgeCount);

            g.RemoveVertex(v2);
            Assert.AreEqual(vertexCount + 1, g.VertexCount);
            Assert.AreEqual(edgeCount, g.EdgeCount);
            Assert.IsTrue(g.ContainsVertex(v1));
            Assert.IsFalse(g.ContainsVertex(v2));
            VerifyCounts(g);
        }