public void Sort()
        {
            AdjacencyGraph g = new AdjacencyGraph(new VertexAndEdgeProvider(), true);
            Hashtable iv = new Hashtable();

            int i = 0;
            IVertex a = g.AddVertex();
            iv[i++]=a;
            IVertex b = g.AddVertex();
            iv[i++]=b;
            IVertex c = g.AddVertex();
            iv[i++]=c;
            IVertex d = g.AddVertex();
            iv[i++]=d;
            IVertex e = g.AddVertex();
            iv[i++]=e;

            g.AddEdge(a,b);
            g.AddEdge(a,c);
            g.AddEdge(b,c);
            g.AddEdge(c,d);
            g.AddEdge(a,e);

            TopologicalSortAlgorithm topo = new TopologicalSortAlgorithm(g);
            topo.Compute();

            for(int j=0;j<topo.SortedVertices.Count;++j)
            {
                Assert.AreEqual( (IVertex)iv[j], topo.SortedVertices[j]);
            }
        }
		public void Sort()
		{
			AdjacencyGraph g = new AdjacencyGraph(true);
			Hashtable iv = new Hashtable();
			
			int i = 0;
			IVertex a = g.AddVertex();
			iv[i++]=a;
			IVertex b = g.AddVertex();
			iv[i++]=b;
			IVertex c = g.AddVertex();
			iv[i++]=c;
			IVertex d = g.AddVertex();
			iv[i++]=d;
			IVertex e = g.AddVertex();
			iv[i++]=e;

			g.AddEdge(a,b);
			g.AddEdge(a,c);
			g.AddEdge(b,c);
			g.AddEdge(c,d);				
			g.AddEdge(a,e);				

			TopologicalSortAlgorithm topo = new TopologicalSortAlgorithm(g);
			topo.Compute();
		}
        public static AdjacencyGraph CreateAcyclicGraph(
            VertexAndEdgeProvider provider_iVertexAndEdgeProvider,
            bool allowParallelEdges_b,
            int numberOfVertices
            )
        {
            PexAssume.IsTrue(numberOfVertices < 50);

            AdjacencyGraph adjacencyGraph
               = new AdjacencyGraph(provider_iVertexAndEdgeProvider, allowParallelEdges_b);

            IVertex u = adjacencyGraph.AddVertex();
            IVertex v = adjacencyGraph.AddVertex();
            IVertex w = adjacencyGraph.AddVertex();
            adjacencyGraph.AddEdge(u, v);
            adjacencyGraph.AddEdge(v, w);
            adjacencyGraph.AddEdge(u, w);

            //Adding remaining number of vertices
            for (int count = 3; count < numberOfVertices; count++)
            {
                adjacencyGraph.AddVertex();
            }

            return adjacencyGraph;
        }
        public void CheckPredecessorLineGraph()
        {
            AdjacencyGraph g = new AdjacencyGraph(true);
            IVertex v1 = g.AddVertex();
            IVertex v2 = g.AddVertex();
            IVertex v3 = g.AddVertex();

            IEdge e12 = g.AddEdge(v1,v2);
            IEdge e23 = g.AddEdge(v2,v3);

            EdgeDoubleDictionary weights = DijkstraShortestPathAlgorithm.UnaryWeightsFromEdgeList(g);
            DijkstraShortestPathAlgorithm dij = new DijkstraShortestPathAlgorithm(g,weights);
            PredecessorRecorderVisitor vis = new PredecessorRecorderVisitor();
            dij.RegisterPredecessorRecorderHandlers(vis);

            dij.Compute(v1);

            EdgeCollection col = vis.Path(v2);
            Assert.AreEqual(1,col.Count);
            Assert.AreEqual(e12,col[0]);

            col = vis.Path(v3);
            Assert.AreEqual(2,col.Count);
            Assert.AreEqual(e12,col[0]);
            Assert.AreEqual(e23,col[1]);
        }
		public void TwoVertexCycle()
		{
			AdjacencyGraph g =new AdjacencyGraph(true);
			IVertex v1 = g.AddVertex();
			IVertex v2 = g.AddVertex();
			IEdge e1 = g.AddEdge(v1,v2);
			IEdge e2 = g.AddEdge(v2,v1);
			StrongComponentsAlgorithm strong = new StrongComponentsAlgorithm(g);
			Assert.AreEqual(1, strong.Compute());

			checkStrong(strong);
		}
        public MaximumFlowDemo()
        {
            graph = new AdjacencyGraph(
                new NamedVertexProvider(),
                new EdgeProvider(),
                true);

            s = (NamedVertex)graph.AddVertex(); s.Name = "s";
            x = (NamedVertex)graph.AddVertex(); x.Name = "x";
            v = (NamedVertex)graph.AddVertex(); v.Name = "v";
            w = (NamedVertex)graph.AddVertex(); w.Name = "w";
            t = (NamedVertex)graph.AddVertex(); t.Name = "t";

            sx = graph.AddEdge(s, x); capacities[sx] = 5;
            sv = graph.AddEdge(s, v); capacities[sv] = 7;
            xv = graph.AddEdge(x, v); capacities[xv] = 3;
            xw = graph.AddEdge(x, w); capacities[xw] = 7;
            wv = graph.AddEdge(w, v); capacities[wv] = 5;
            wt = graph.AddEdge(w, t); capacities[wt] = 4;
            vt = graph.AddEdge(v, t); capacities[vt] = 6;

            this.graphviz = new GraphvizAlgorithm(this.graph);
            this.graphviz.ImageType = NGraphviz.Helpers.GraphvizImageType.Svg;
            this.graphviz.GraphFormat.RankDirection = NGraphviz.Helpers.GraphvizRankDirection.LR;
            this.graphviz.FormatVertex+=new FormatVertexEventHandler(graphviz_FormatVertex);
            this.graphviz.FormatEdge+=new FormatEdgeEventHandler(graphviz_FormatEdge);

            this.reversedEdgeAugmentor = new ReversedEdgeAugmentorAlgorithm(this.graph);
            this.reversedEdgeAugmentor.ReversedEdgeAdded += new EdgeEventHandler(reversedEdgeAugmentor_ReversedEdgeAdded);
        }
		public void RunOnLineGraph()
		{
			AdjacencyGraph g = new AdjacencyGraph(true); 
			IVertex v1 = g.AddVertex();
			IVertex v2 = g.AddVertex();
			IVertex v3 = g.AddVertex();

			IEdge e12 = g.AddEdge(v1,v2);
			IEdge e23 = g.AddEdge(v2,v3);

			EdgeDoubleDictionary weights = DijkstraShortestPathAlgorithm.UnaryWeightsFromEdgeList(g);
			DijkstraShortestPathAlgorithm dij = new DijkstraShortestPathAlgorithm(g,weights);
			dij.Compute(v1);

			Assert.AreEqual(0, dij.Distances[v1]);
			Assert.AreEqual(1, dij.Distances[v2]);
			Assert.AreEqual(2, dij.Distances[v3]);
		}
        public void RootIsNotAccessible()
        {
            AdjacencyGraph g = new AdjacencyGraph();
            IVertex root = g.AddVertex();
            IVertex v = g.AddVertex();
            g.AddEdge(root, v);

            target = new CyclePoppingRandomTreeAlgorithm(g);
            target.RandomTreeWithRoot(root);
        }
 /// <summary>
 /// Star canal
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public static AdjacencyGraph CreateStar(int n)
 {
     AdjacencyGraph g = new AdjacencyGraph();
     IVertex root = g.AddVertex();
     for(int i = 0;i<n;++i)
     {
         IVertex v = g.AddVertex();
         g.AddEdge(root, v);
     }
     return g;
 }
 /// <summary>
 /// Reversed star canal
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public static AdjacencyGraph CreateReversedStart(int n)
 {
     AdjacencyGraph g = new AdjacencyGraph();
     IVertex root = g.AddVertex();
     for(int i = 0;i<n;++i)
     {
         IVertex v = g.AddVertex();
         g.AddEdge(v,root);
     }
     return g;
 }
 public AdjacencyGraph createCycle(AdjacencyGraph g)
 {
     foreach (IVertex v1 in g.Vertices)
     {
         foreach (IVertex v2 in g.Vertices)
         {
             if (v1 != v2 && g.ContainsEdge(v1, v2))
             {
                 g.AddEdge(v1, v2);
             }
         }
     }
     return g;
 }
        /// <summary>
        /// Cascade graph
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static AdjacencyGraph CreateCascade(int n)
        {
            IVertex previous, next;

            AdjacencyGraph g = new AdjacencyGraph();
            next = g.AddVertex();
            for(int i = 0;i<n;++i)
            {
                previous = next;
                next = g.AddVertex();
                g.AddEdge(previous,next);
            }
            return g;
        }
        public void AddAndRemoveOneEdge()
        {
            AdjacencyGraph g = new AdjacencyGraph();
            IVertex v = g.AddVertex();
            IVertex u = g.AddVertex();
            IEdge edge = g.AddEdge(u, v);

            this.target = new ReversedEdgeAugmentorAlgorithm(g);
            target.AddReversedEdges();
            target.RemoveReversedEdges();
            Assert.AreEqual(2, this.target.VisitedGraph.VerticesCount);
            Assert.AreEqual(1, this.target.VisitedGraph.EdgesCount);
            CollectionAssert.AreCountEqual(0, this.target.AugmentedEdges);
            Assert.AreEqual(0, this.target.ReversedEdges.Count);
        }
        public void AddOneEdge()
        {
            AdjacencyGraph g = new AdjacencyGraph();
            IVertex v = g.AddVertex();
            IVertex u = g.AddVertex();
            IEdge edge = g.AddEdge(u, v);

            this.target = new ReversedEdgeAugmentorAlgorithm(g);
            target.AddReversedEdges();

            Assert.AreEqual(2, this.target.VisitedGraph.VerticesCount);
            Assert.AreEqual(2, this.target.VisitedGraph.EdgesCount);
            CollectionAssert.AreCountEqual(1, this.target.AugmentedEdges);
            VerifyReversedEdges();

            IEdge reversedEdge = this.target.ReversedEdges[edge];
            Assert.IsNotNull(reversedEdge);
            Assert.IsTrue(this.target.AugmentedEdges.Contains(reversedEdge));
        }
        public void GraphWithSelfEdgesPUT(AdjacencyGraph g, int loopBound)
        {
            Random rnd = new Random();
            Init();
            for (int i = 0; i < loopBound; ++i)
            {
                for (int j = 0; j < i * i; ++j)
                {
                    RandomGraph.Graph(g, i, j, rnd, true);
                    BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm(g);
                    bfs.InitializeVertex += new VertexHandler(this.InitializeVertex);
                    bfs.DiscoverVertex += new VertexHandler(this.DiscoverVertex);
                    bfs.ExamineEdge += new EdgeHandler(this.ExamineEdge);
                    bfs.ExamineVertex += new VertexHandler(this.ExamineVertex);
                    bfs.TreeEdge += new EdgeHandler(this.TreeEdge);
                    bfs.NonTreeEdge += new EdgeHandler(this.NonTreeEdge);
                    bfs.GrayTarget += new EdgeHandler(this.GrayTarget);
                    bfs.BlackTarget += new EdgeHandler(this.BlackTarget);
                    bfs.FinishVertex += new VertexHandler(this.FinishVertex);

                    Parents.Clear();
                    Distances.Clear();
                    m_CurrentDistance = 0;

                    m_SourceVertex = RandomGraph.Vertex(g, rnd);
                    var choose = PexChoose.FromCall(this);
                    if(choose.ChooseValue<bool>("to add a self ede"))
                    {
                        IVertex selfEdge = RandomGraph.Vertex(g, rnd);
                        g.AddEdge(selfEdge, selfEdge);
                    }
                    // g.RemoveEdge(RandomGraph.Edge(g, rnd));
                    foreach (IVertex v in g.Vertices)
                    {
                        Distances[v] = int.MaxValue;
                        Parents[v] = v;
                    }
                    Distances[SourceVertex] = 0;
                    bfs.Compute(SourceVertex);

                    CheckBfs(g, bfs);
                }
            }
        }
        public void GraphWithSelfEdgesPUT(AdjacencyGraph g, int loopBound, bool self)
        {
            Random rnd; //new Random();
            var choose1 = PexChoose.FromCall(this);
            rnd = choose1.ChooseValue<Random>("Random object");
            Init();
            for (int i = 0; i < loopBound; ++i)
            {
                for (int j = 0; j < i * i; ++j)
                {
                    RandomGraph.Graph(g, i, j, rnd, true);
                    Init();
                    DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(g);
                    dfs.StartVertex += new VertexHandler(this.StartVertex);
                    dfs.DiscoverVertex += new VertexHandler(this.DiscoverVertex);
                    dfs.ExamineEdge += new EdgeHandler(this.ExamineEdge);
                    dfs.TreeEdge += new EdgeHandler(this.TreeEdge);
                    dfs.BackEdge += new EdgeHandler(this.BackEdge);
                    dfs.ForwardOrCrossEdge += new EdgeHandler(this.FowardOrCrossEdge);
                    dfs.FinishVertex += new VertexHandler(this.FinishVertex);

                    Parents.Clear();
                    DiscoverTimes.Clear();
                    FinishTimes.Clear();
                    m_Time = 0;

                    foreach (IVertex v in g.Vertices)
                        Parents[v] = v;

                    var choose = PexChoose.FromCall(this);
                    if (choose.ChooseValue<bool>("to add a self ede"))
                    {
                        IVertex selfEdge = RandomGraph.Vertex(g, rnd);
                        g.AddEdge(selfEdge, selfEdge);
                    }
                    // compute
                    dfs.Compute();

                    CheckDfs(g, dfs);
                }
            }
        }
        public void SortCyclic()
        {
            AdjacencyGraph g = new AdjacencyGraph(new VertexAndEdgeProvider(), true);

            IVertex a = g.AddVertex();
            IVertex b = g.AddVertex();
            IVertex c = g.AddVertex();
            IVertex d = g.AddVertex();
            IVertex e = g.AddVertex();

            g.AddEdge(a,b);
            g.AddEdge(a,c);
            g.AddEdge(b,c);
            g.AddEdge(c,d);
            g.AddEdge(a,e);
            g.AddEdge(c,a);

            TopologicalSortAlgorithm topo = new TopologicalSortAlgorithm(g);
            topo.Compute();
        }
        public void Test()
        {
            // create a new adjacency graph
            AdjacencyGraph g = new AdjacencyGraph(false);

            // adding files and storing names
            IVertex boz_h = g.AddVertex();		Names[boz_h]="boz.h";
            IVertex zag_cpp = g.AddVertex();	Names[zag_cpp]="zag.cpp";
            IVertex yow_h = g.AddVertex();		Names[yow_h]="yow.h";
            IVertex dax_h = g.AddVertex();		Names[dax_h]="dax.h";
            IVertex bar_cpp = g.AddVertex();	Names[bar_cpp]="bar.cpp";
            IVertex zow_h = g.AddVertex();		Names[zow_h]="zow.h";
            IVertex foo_cpp = g.AddVertex();	Names[foo_cpp]="foo.cpp";

            IVertex zig_o = g.AddVertex();		Names[zig_o]="zig.o";
            IVertex zag_o = g.AddVertex();		Names[zag_o]="zago";
            IVertex bar_o = g.AddVertex();		Names[bar_o]="bar.o";
            IVertex foo_o = g.AddVertex();		Names[foo_o]="foo.o";
            IVertex libzigzag_a = g.AddVertex();Names[libzigzag_a]="libzigzig.a";
            IVertex libfoobar_a = g.AddVertex();Names[libfoobar_a]="libfoobar.a";

            IVertex killerapp = g.AddVertex();	Names[killerapp]="killerapp";
            IVertex zig_cpp = g.AddVertex();	Names[zig_cpp]="zip.cpp";

            // adding dependencies
            g.AddEdge(dax_h, foo_cpp);
            g.AddEdge(dax_h, bar_cpp);
            g.AddEdge(dax_h, yow_h);
            g.AddEdge(yow_h, bar_cpp);
            g.AddEdge(yow_h, zag_cpp);
            g.AddEdge(boz_h, bar_cpp);
            g.AddEdge(boz_h, zig_cpp);
            g.AddEdge(boz_h, zag_cpp);
            g.AddEdge(zow_h, foo_cpp);
            g.AddEdge(foo_cpp, foo_o);
            g.AddEdge(foo_o, libfoobar_a);
            g.AddEdge(bar_cpp, bar_o);
            g.AddEdge(bar_o, libfoobar_a);
            g.AddEdge(libfoobar_a, libzigzag_a);
            g.AddEdge(zig_cpp, zig_o);
            g.AddEdge(zig_o, libzigzag_a);
            g.AddEdge(zag_cpp, zag_o);
            g.AddEdge(zag_o, libzigzag_a);
            g.AddEdge(libzigzag_a, killerapp);

            Console.WriteLine("Leaves");
            foreach(IVertex v in AlgoUtility.Sinks(g))
            {
                Console.WriteLine(Names[v]);
            }

            Console.WriteLine("Leaves of zag_o");
            foreach(IVertex v in AlgoUtility.Sinks(g,zag_o))
            {
                Console.WriteLine(Names[v]);
            }

            // outputing graph to png
            GraphvizAlgorithm gw = new GraphvizAlgorithm(
                g,                      // graph to draw
                ".",                    // output file path
                GraphvizImageType.Png   // output file type
                );
            // outputing to graph.
            gw.Write("filedependency");
            // adding custom vertex settings
            gw.FormatVertex+=new FormatVertexEventHandler(gw_FormatVertex);
            gw.Write("fp");
        }
Beispiel #19
0
        public void Test()
        {
            // create a new adjacency graph
            AdjacencyGraph g = new AdjacencyGraph(new VertexAndEdgeProvider(), false);

            // adding files and storing names
            IVertex zig_cpp = g.AddVertex();	Names[zig_cpp]="zip.cpp";
            IVertex boz_h = g.AddVertex();		Names[boz_h]="boz.h";
            IVertex zag_cpp = g.AddVertex();	Names[zag_cpp]="zag.cpp";
            IVertex yow_h = g.AddVertex();		Names[yow_h]="yow.h";
            IVertex dax_h = g.AddVertex();		Names[dax_h]="dax.h";
            IVertex bar_cpp = g.AddVertex();	Names[bar_cpp]="bar.cpp";
            IVertex zow_h = g.AddVertex();		Names[zow_h]="zow.h";
            IVertex foo_cpp = g.AddVertex();	Names[foo_cpp]="foo.cpp";

            IVertex zig_o = g.AddVertex();		Names[zig_o]="zig.o";
            IVertex zag_o = g.AddVertex();		Names[zag_o]="zago";
            IVertex bar_o = g.AddVertex();		Names[bar_o]="bar.o";
            IVertex foo_o = g.AddVertex();		Names[foo_o]="foo.o";
            IVertex libzigzag_a = g.AddVertex();Names[libzigzag_a]="libzigzig.a";
            IVertex libfoobar_a = g.AddVertex();Names[libfoobar_a]="libfoobar.a";

            IVertex killerapp = g.AddVertex();	Names[killerapp]="killerapp";

            // adding dependencies
            g.AddEdge(dax_h, foo_cpp);
            g.AddEdge(dax_h, bar_cpp);
            g.AddEdge(dax_h, yow_h);
            g.AddEdge(yow_h, bar_cpp);
            g.AddEdge(yow_h, zag_cpp);
            g.AddEdge(boz_h, bar_cpp);
            g.AddEdge(boz_h, zig_cpp);
            g.AddEdge(boz_h, zag_cpp);
            g.AddEdge(zow_h, foo_cpp);
            g.AddEdge(foo_cpp, foo_o);
            g.AddEdge(foo_o, libfoobar_a);
            g.AddEdge(bar_cpp, bar_o);
            g.AddEdge(bar_o, libfoobar_a);
            g.AddEdge(libfoobar_a, libzigzag_a);
            g.AddEdge(zig_cpp, zig_o);
            g.AddEdge(zig_o, libzigzag_a);
            g.AddEdge(zag_cpp, zag_o);
            g.AddEdge(zag_o, libzigzag_a);
            g.AddEdge(libzigzag_a, killerapp);

            // outputing graph to png
            GraphvizAlgorithm gw = new GraphvizAlgorithm(
                g,                      // graph to draw
                "filedependency",         // output file prefix
                ".",                    // output file path
                GraphvizImageType.Png   // output file type
                );
            // outputing to graph.
            gw.Write();

            // attaching the file name outputer...
            gw.WriteVertex += new VertexHandler(this.WriteVertex);
            gw.Write();
        }
        /// <summary>
        /// entry point for the application.
        /// </summary>		
        public void Test(string outputImageFolder)
        {
            AdjacencyGraph g = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true);

            MyVertex[] v = new MyVertex[12];
            for( int i=0; i<12;i++)	{
                v[i] = (MyVertex) g.AddVertex();
                v[i].Name = "Vertex " + i;
                v[i].Value = i;
            }
            g.AddEdge(v[0], v[1]);
            g.AddEdge(v[1], v[2]);
            g.AddEdge(v[2], v[3]);
            g.AddEdge(v[3], v[0]);
            g.AddEdge(v[2], v[0]);
            g.AddEdge(v[4], v[5]);
            g.AddEdge(v[5], v[6]);
            g.AddEdge(v[6], v[7]);
            g.AddEdge(v[7], v[4]);
            g.AddEdge(v[2], v[5]);
            g.AddEdge(v[8], v[9]);
            g.AddEdge(v[9], v[8]);
            g.AddEdge(v[10], v[11]);
            g.AddEdge(v[11], v[10]);
            g.AddEdge(v[2], v[9]);
            g.AddEdge(v[9], v[10]);

            GraphvizAlgorithm renderer = new GraphvizAlgorithm(g,outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg);
            renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph);
            renderer.Write("Original_Graph.jpeg");

            CondensationGraphAlgorithm cgalgo = new CondensationGraphAlgorithm( g );
            cgalgo.InitCondensationGraphVertex += new CondensationGraphVertexEventHandler(CGVertexHandler);

            AdjacencyGraph cg = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true);
            cgalgo.Create(cg);

            //	Render the Condensation Graph
            renderer = new GraphvizAlgorithm(cg, outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg);
            renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph);
            renderer.Write("CG.jpeg");
        }
        /// <summary>
        /// Entry point for the application.
        /// </summary>		
        public static void Test(string outputImageFolder)
        {
            AdjacencyGraph g = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true);

            MyVertex[] v = new MyVertex[12];
            for( int i=0; i<12;i++)	{
                v[i] = (MyVertex) g.AddVertex();
                v[i].Name = "Vertex " + i;
                v[i].Value = i;
            }
            g.AddEdge(v[0], v[1]);
            g.AddEdge(v[1], v[2]);
            g.AddEdge(v[2], v[3]);
            g.AddEdge(v[3], v[0]);
            g.AddEdge(v[2], v[0]);
            g.AddEdge(v[4], v[5]);
            g.AddEdge(v[5], v[6]);
            g.AddEdge(v[6], v[7]);
            g.AddEdge(v[7], v[4]);
            g.AddEdge(v[2], v[5]);
            g.AddEdge(v[8], v[9]);
            g.AddEdge(v[9], v[8]);
            g.AddEdge(v[10], v[11]);
            g.AddEdge(v[11], v[10]);
            g.AddEdge(v[2], v[9]);
            g.AddEdge(v[9], v[10]);

            GraphvizAlgorithm renderer = new GraphvizAlgorithm(g,outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg);
            renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph);
            renderer.Write("Original_Graph.jpeg");

            TransitiveClosureAlgorithm tcalgo = new TransitiveClosureAlgorithm(g);
            AdjacencyGraph tc = new AdjacencyGraph(new MyVertexProvider(), new EdgeProvider(), true);
            tcalgo.InitTransitiveClosureVertex += new TransitiveClosureVertexEventHandler(MapTCVertex);
            tcalgo.ExamineEdge += new EdgeEventHandler(InitEdge);
            tcalgo.Create(tc);

            renderer = new GraphvizAlgorithm(tc, outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg);
            renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph);
            renderer.Write("TC.jpeg");
        }
        public static AdjacencyGraph FileDependency()
        {
            // create a new adjacency graph
            AdjacencyGraph g = new AdjacencyGraph(
                new NamedVertexProvider(),
                new NamedEdgeProvider(),
                true
                );

            // adding files and storing names
            NamedVertex zig_cpp = (NamedVertex)g.AddVertex();	zig_cpp.Name="zip.cpp";
            NamedVertex boz_h = (NamedVertex)g.AddVertex();		boz_h.Name="boz.h";
            NamedVertex zag_cpp = (NamedVertex)g.AddVertex();	zag_cpp.Name="zag.cpp";
            NamedVertex yow_h = (NamedVertex)g.AddVertex();		yow_h.Name="yow.h";
            NamedVertex dax_h = (NamedVertex)g.AddVertex();		dax_h.Name="dax.h";
            NamedVertex bar_cpp = (NamedVertex)g.AddVertex();	bar_cpp.Name="bar.cpp";
            NamedVertex zow_h = (NamedVertex)g.AddVertex();		zow_h.Name="zow.h";
            NamedVertex foo_cpp = (NamedVertex)g.AddVertex();	foo_cpp.Name="foo.cpp";

            NamedVertex zig_o = (NamedVertex)g.AddVertex();		zig_o.Name="zi.o";
            NamedVertex zag_o = (NamedVertex)g.AddVertex();		zag_o.Name="zag.o";
            NamedVertex bar_o = (NamedVertex)g.AddVertex();		bar_o.Name="bar.o";
            NamedVertex foo_o = (NamedVertex)g.AddVertex();		foo_o.Name="foo.o";
            NamedVertex libzigzag_a = (NamedVertex)g.AddVertex(); libzigzag_a.Name="libzigzag.a";
            NamedVertex libfoobar_a = (NamedVertex)g.AddVertex(); libfoobar_a.Name="libfoobar.a";

            NamedVertex killerapp = (NamedVertex)g.AddVertex();	killerapp.Name="killerapp";

            // adding dependencies
            g.AddEdge(dax_h, foo_cpp);
            g.AddEdge(dax_h, bar_cpp);
            g.AddEdge(dax_h, yow_h);
            g.AddEdge(yow_h, bar_cpp);
            g.AddEdge(yow_h, zag_cpp);
            g.AddEdge(boz_h, bar_cpp);
            g.AddEdge(boz_h, zig_cpp);
            g.AddEdge(boz_h, zag_cpp);
            g.AddEdge(zow_h, foo_cpp);
            g.AddEdge(foo_cpp, foo_o);
            g.AddEdge(foo_o, libfoobar_a);
            g.AddEdge(bar_cpp, bar_o);
            g.AddEdge(bar_o, libfoobar_a);
            g.AddEdge(libfoobar_a, libzigzag_a);
            g.AddEdge(zig_cpp, zig_o);
            g.AddEdge(zig_o, libzigzag_a);
            g.AddEdge(zag_cpp, zag_o);
            g.AddEdge(zag_o, libzigzag_a);
            g.AddEdge(libzigzag_a, killerapp);

            return g;
        }