示例#1
0
 public void TearDown()
 {
     if (this.augmentor != null)
     {
         this.augmentor.Rollback();
         this.augmentor = null;
     }
 }
示例#2
0
 public void SetUp(IMutableVertexAndEdgeListGraph <string, Edge <string> > g)
 {
     this.augmentor = new AllVerticesGraphAugmentorAlgorithm <string, Edge <string> >(
         g,
         new StringVertexFactory(),
         new EdgeFactory <string>()
         );
 }
示例#3
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));
 }
示例#4
0
 private static void VerifySinkConnector <TVertex, TEdge>(
     IMutableVertexAndEdgeListGraph <TVertex, TEdge> g,
     AllVerticesGraphAugmentorAlgorithm <TVertex, TEdge> augmentor)
     where TEdge : IEdge <TVertex>
 {
     foreach (var v in g.Vertices)
     {
         if (v.Equals(augmentor.SuperSink))
         {
             continue;
         }
         if (v.Equals(augmentor.SuperSink))
         {
             continue;
         }
         Assert.True(g.ContainsEdge(v, augmentor.SuperSink));
     }
 }
示例#5
0
        private void Augment(
            IMutableVertexAndEdgeListGraph <string, Edge <string> > g)
        {
            int vertexCount = g.VertexCount;
            int edgeCount   = g.EdgeCount;
            int vertexId    = g.VertexCount + 1;
            int edgeID      = g.EdgeCount + 1;

            using (var augmentor = new AllVerticesGraphAugmentorAlgorithm <string, Edge <string> >(
                       g,
                       () => (vertexId++).ToString(),
                       (s, t) => new Edge <string>(s, t)
                       ))
            {
                augmentor.Compute();
                VerifyCount(g, augmentor, vertexCount);
                VerifySourceConnector(g, augmentor);
                VerifySinkConnector(g, augmentor);
            }
            Assert.Equal(g.VertexCount, vertexCount);
            Assert.Equal(g.EdgeCount, edgeCount);
        }