public static void TestCaseBook() { // 1. Create a graph CGraph mgraph = CGraph.CreateGraph(); CGraphNode u = mgraph.CreateGraphNode <CGraphNode>("u"); CGraphNode v = mgraph.CreateGraphNode <CGraphNode>("v"); CGraphNode w = mgraph.CreateGraphNode <CGraphNode>("w"); CGraphNode x = mgraph.CreateGraphNode <CGraphNode>("x"); CGraphNode y = mgraph.CreateGraphNode <CGraphNode>("y"); CGraphNode z = mgraph.CreateGraphNode <CGraphNode>("z"); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(u, v, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(u, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x, v, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(v, y, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(y, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(w, y, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(w, z, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(z, z, GraphType.GT_DIRECTED); DepthFirstSearch dfs = new DepthFirstSearch(mgraph); dfs.Run(); DepthFirstSearchQueryInfo info = new DepthFirstSearchQueryInfo(mgraph, dfs); CIt_GraphNodes it = new CIt_GraphNodes(mgraph); for (it.Begin(); !it.End(); it.Next()) { Console.WriteLine("Node {0}: arrival ({1}) - departure ({2})", it.M_CurrentItem.M_Label, info.Arrival(it.M_CurrentItem), info.Departure(it.M_CurrentItem)); } }
public static void TestCaseBook() { // 1. Create a graph CGraph mgraph = CGraph.CreateGraph(); CGraphNode r = mgraph.CreateGraphNode <CGraphNode>("r"); CGraphNode s = mgraph.CreateGraphNode <CGraphNode>("s"); CGraphNode t = mgraph.CreateGraphNode <CGraphNode>("t"); CGraphNode u = mgraph.CreateGraphNode <CGraphNode>("u"); CGraphNode v = mgraph.CreateGraphNode <CGraphNode>("v"); CGraphNode w = mgraph.CreateGraphNode <CGraphNode>("w"); CGraphNode x = mgraph.CreateGraphNode <CGraphNode>("x"); CGraphNode y = mgraph.CreateGraphNode <CGraphNode>("y"); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(r, s, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(r, v, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(s, w, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(w, t, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(w, x, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, x, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, u, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x, u, GraphType.GT_UNDIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x, y, GraphType.GT_UNDIRECTED); // 2. Create Algorithm BreadthFirstSearch bfs = new BreadthFirstSearch(s, mgraph); // 2. Associate weights with the edges of the graph CGraphQueryInfo <int, int, int> bfsData = new CGraphQueryInfo <int, int, int>(mgraph, bfs); bfs.Run(); Console.WriteLine("Printing BFS Results with Source Node : {0}", s.M_Label); foreach (CGraphNode node in bfs.BFSNodes()) { Console.WriteLine("Node {0} distance: {1}", node.M_Label, bfs.Distance(node)); } // Testing BreadthFirstSearchQueryInfo BreadthFirstSearchQueryInfo bfsInfo = new BreadthFirstSearchQueryInfo(mgraph, bfs); Console.WriteLine("Printing BFS Results with Source Node : {0}", s.M_Label); foreach (CGraphNode node in bfsInfo.BFSNodes()) { Console.WriteLine("Node {0} distance: {1}", node.M_Label, bfs.Distance(node)); } }
static void Main(string[] args) { CTranslationUnit tr = new CTranslationUnit(); CGraph graph = CGraph.CreateGraph(); tr.dipole() .algorithm() .algorithm() .connections() .connection() .GRAPH(graph) .GRAPHELEMENTTYPE(GraphElementType.ET_NODE) .KEY(graph.GetHashCode()) .INFOTYPE(typeof(int)) .end() .end(); }
static void Main(string[] args) { CGraph graph1 = CGraph.CreateGraph(); CGraph graph2 = CGraph.CreateGraph(); CGraph rootGraph = CGraph.CreateGraph(); // CREATE A GRAPH FROM A CSV FILE // We call the CreateGraphFromCSV where the edges are given as comma separated // tuples in curly brackets. Sole nodes can be given inside curle brackets. This // method assigns node labels as given in the file using the native graph labeller CGraph graph3 = CGraph.CreateGraphFromCSV("csvGraph.txt"); CGraph.CCloneGraphOperation cloner = new CGraph.CCloneGraphOperation(); CGraph graph3Clone = cloner.CloneGraph(graph3); CGraph.CMergeGraphOperation joiner = new CGraph.CMergeGraphOperation(); joiner.MergeGraph(graph3); CGraph mergedGraph = joiner.MergeGraph(graph3Clone); Console.WriteLine("{0}", mergedGraph.ToString()); // The graph can be printed using the specified graph printer which optionally can // take a label contructor. If the label contractor is ommited that printer will recieve // labels from the native graph labeller. In this case this what it happens graph3.RegisterGraphPrinter(new CGraphVizPrinter(graph3)); graph3Clone.RegisterGraphPrinter(new CGraphVizPrinter(graph3Clone)); mergedGraph.RegisterGraphPrinter(new CGraphVizPrinter(mergedGraph)); // The graph uses the registered printers to print the graph to the specified output graph3.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\test3.dot", true); graph3Clone.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\test3Clone.dot", true); mergedGraph.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\MergeTest.dot", true); /* * AlgorithmDataRecord ioargs = * GAlg_LeaderFinder_Builder.Create(). * Input_SourceGraph(graph3). * End(); * * GAlg_LeaderFinder bbFinder = new GAlg_LeaderFinder(ioargs); * bbFinder.Init(); * /* * GAlg_BasicBlocks bbCreate = new GAlg_BasicBlocks(graph3,bbFinder); * bbCreate.Init(); * * // We call the CreateGraphFromCSV where the edges are given as comma separated * // tuples in curly brackets. Sole nodes can be given inside curle brackets. This * // method assigns node labels as given in the file using the native graph labeller * CGraph graph4 = CGraph.CreateGraphFromCSV("csvGraph1.txt"); * * graph4.RegisterGraphPrinter(new CGraphVizPrinter(graph4)); * // The graph uses the registered printers to print the graph to the specified output * graph4.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\test4.dot", true); * * GAlg_ExtendedBasicBlockFinder ebbFinder = new GAlg_ExtendedBasicBlockFinder(graph4); * ebbFinder.Init(); * * // We call the CreateGraphFromCSV where the edges are given as comma separated * // tuples in curly brackets. Sole nodes can be given inside curle brackets. This * // method assigns node labels as given in the file using the native graph labeller * CGraph graph5 = CGraph.CreateGraphFromCSV("csvGraph2.txt"); * * graph5.RegisterGraphPrinter(new CGraphVizPrinter(graph5)); * // The graph uses the registered printers to print the graph to the specified output * graph5.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\csvGraph2.dot", true); * * GAlg_DFSSpanningTree dfsSpanningTree = new GAlg_DFSSpanningTree(graph5); * dfsSpanningTree.Init(); * * dfsSpanningTree.m_dfsSpanningTree.RegisterGraphPrinter(new CDFSSpanningTreeGraphvizPrinter(dfsSpanningTree.m_dfsSpanningTree)); * dfsSpanningTree.m_dfsSpanningTree.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\ST.dot", true); * * // CREATE A GRAPH FROM RANDOM GRAPH GENERATORS * // A random graph with the specified number of nodes and edges can be generated * // using the GenerateGraph_RandomGraph method. The nodes are labelled in the native * // graph labeller using their serial numbers * graph1.GenerateGraph_RandomGraph(10,40,GraphType.GT_UNDIRECTED); * // The graph can be printed using the specified graph printer which optionally can * // take a label contructor. If the label contractor is ommited that printer will recieve * // labels from the native graph labeller. In this case this what it happens * graph1.RegisterGraphPrinter(new CGraphVizPrinter(graph1)); * // The graph uses the registered printers to print the graph to the specified output * //graph1.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\graph1.dot", true); * * graph2.GenerateGraph_RandomGraph(10,40,GraphType.GT_UNDIRECTED); * graph2.RegisterGraphPrinter(new CGraphVizPrinter(graph2)); * //graph2.Generate(@"E:\MyPrivateWork\MyApps\MyLibraries\GraphLibrary\TestGraphLibrary\bin\Debug\graph2.dot", true);*/ }
public static void BookExampleTestcase() { // 1. Create a graph CGraph mgraph = CGraph.CreateGraph(); CGraphNode x = mgraph.CreateGraphNode <CGraphNode>("x"); CGraphNode y = mgraph.CreateGraphNode <CGraphNode>("y"); CGraphNode z = mgraph.CreateGraphNode <CGraphNode>("z"); CGraphNode t = mgraph.CreateGraphNode <CGraphNode>("t"); CGraphNode s = mgraph.CreateGraphNode <CGraphNode>("s"); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, y, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, z, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x, t, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(y, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(y, z, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(z, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(z, s, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(s, t, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(s, y, GraphType.GT_DIRECTED); // 2. Associate weights with the edges of the graph CGraphQueryInfo <int, int, int> weights = new CGraphQueryInfo <int, int, int>(mgraph, 255); weights.CreateInfo(y, x, -3); weights.CreateInfo(x, t, -2); weights.CreateInfo(t, x, 5); weights.CreateInfo(z, x, 7); weights.CreateInfo(y, z, 9); weights.CreateInfo(t, y, 8); weights.CreateInfo(t, z, -4); weights.CreateInfo(s, t, 6); weights.CreateInfo(s, y, 7); weights.CreateInfo(z, s, 2); // 3. Run the BellmanFord algorithm BellmanFord bl = new BellmanFord(mgraph, s, 255); bl.FindAllPairsShortestPaths(); // 4. Print Paths CGraphQueryInfo <int, int, Dictionary <CGraphNode, Dictionary <CGraphNode, Path> > > shortestPath = new CGraphQueryInfo <int, int, Dictionary <CGraphNode, Dictionary <CGraphNode, Path> > >(mgraph, bl); CIt_GraphNodes i = new CIt_GraphNodes(mgraph); CIt_GraphNodes j = new CIt_GraphNodes(mgraph); Dictionary <CGraphNode, Dictionary <CGraphNode, Path> > paths = (Dictionary <CGraphNode, Dictionary <CGraphNode, Path> >)(shortestPath.Info()); for (i.Begin(); !i.End(); i.Next()) { Console.WriteLine(); for (j.Begin(); !j.End(); j.Next()) { Console.WriteLine(); if (i.M_CurrentItem != j.M_CurrentItem) { Console.Write(paths[i.M_CurrentItem][j.M_CurrentItem]); } } } }
public static void TestCase3x3() { // 1. Create a graph CGraph mgraph = CGraph.CreateGraph(); CGraphNode x1 = mgraph.CreateGraphNode <CGraphNode>("1"); CGraphNode x2 = mgraph.CreateGraphNode <CGraphNode>("2"); CGraphNode x3 = mgraph.CreateGraphNode <CGraphNode>("3"); CGraphNode x4 = mgraph.CreateGraphNode <CGraphNode>("4"); CGraphNode x5 = mgraph.CreateGraphNode <CGraphNode>("5"); CGraphNode x6 = mgraph.CreateGraphNode <CGraphNode>("6"); CGraphNode x7 = mgraph.CreateGraphNode <CGraphNode>("7"); CGraphNode x8 = mgraph.CreateGraphNode <CGraphNode>("8"); CGraphNode x9 = mgraph.CreateGraphNode <CGraphNode>("9"); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x1, x2, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x2, x1, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x1, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x1, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x1, x4, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x4, x1, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x2, x4, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x4, x2, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x2, x3, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x3, x2, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x2, x6, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x6, x2, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x2, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x2, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x3, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x3, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x3, x6, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x6, x3, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x4, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x4, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x4, x7, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x7, x4, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x4, x8, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x8, x4, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x6, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x6, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x7, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x7, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x8, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x8, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x5, x9, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x9, x5, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x6, x8, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x8, x6, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x6, x9, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x9, x6, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x7, x8, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x8, x7, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x8, x9, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x9, x8, GraphType.GT_DIRECTED); // 2. Associate weights with the edges of the graph CGraphQueryInfo <int, int, int> weights = new CGraphQueryInfo <int, int, int>(mgraph, 255); weights.CreateInfo(x1, x2, 1); weights.CreateInfo(x2, x1, 1); weights.CreateInfo(x1, x5, 1); weights.CreateInfo(x5, x1, 1); weights.CreateInfo(x1, x4, 1); weights.CreateInfo(x4, x1, 1); weights.CreateInfo(x2, x4, 3); weights.CreateInfo(x4, x2, 3); weights.CreateInfo(x2, x3, 1); weights.CreateInfo(x3, x2, 1); weights.CreateInfo(x2, x6, 3); weights.CreateInfo(x6, x2, 3); weights.CreateInfo(x2, x5, 1); weights.CreateInfo(x5, x2, 1); weights.CreateInfo(x3, x5, 3); weights.CreateInfo(x5, x3, 3); weights.CreateInfo(x3, x6, 1); weights.CreateInfo(x6, x3, 1); weights.CreateInfo(x4, x5, 1); weights.CreateInfo(x5, x4, 1); weights.CreateInfo(x4, x7, 1); weights.CreateInfo(x7, x4, 1); weights.CreateInfo(x4, x8, 3); weights.CreateInfo(x8, x4, 3); weights.CreateInfo(x5, x6, 1); weights.CreateInfo(x6, x5, 1); weights.CreateInfo(x5, x7, 3); weights.CreateInfo(x7, x5, 3); weights.CreateInfo(x5, x8, 1); weights.CreateInfo(x8, x5, 1); weights.CreateInfo(x5, x9, 3); weights.CreateInfo(x9, x5, 3); weights.CreateInfo(x6, x8, 3); weights.CreateInfo(x8, x6, 3); weights.CreateInfo(x6, x9, 1); weights.CreateInfo(x9, x6, 1); weights.CreateInfo(x7, x8, 1); weights.CreateInfo(x8, x7, 1); weights.CreateInfo(x8, x9, 1); weights.CreateInfo(x9, x8, 1); // 3. Run the BellmanFord algorithm BellmanFord bl = new BellmanFord(mgraph, x1, 255); bl.FindAllPairsShortestPaths(); // 4. Print Paths BellmanFordQueryInfo shortestPath = new BellmanFordQueryInfo(mgraph, bl); CIt_GraphNodes i = new CIt_GraphNodes(mgraph); CIt_GraphNodes j = new CIt_GraphNodes(mgraph); Dictionary <CGraphNode, Dictionary <CGraphNode, Path> > paths = shortestPath.ShortestPaths(); for (i.Begin(); !i.End(); i.Next()) { Console.WriteLine(); for (j.Begin(); !j.End(); j.Next()) { Console.WriteLine(); if (i.M_CurrentItem != j.M_CurrentItem) { Console.Write(paths[i.M_CurrentItem][j.M_CurrentItem]); } } } }
static void Main(string[] args) { // 1. Create a graph CGraph mgraph = CGraph.CreateGraph(); CGraphNode x = mgraph.CreateGraphNode <CGraphNode>("x"); CGraphNode y = mgraph.CreateGraphNode <CGraphNode>("y"); CGraphNode z = mgraph.CreateGraphNode <CGraphNode>("z"); CGraphNode t = mgraph.CreateGraphNode <CGraphNode>("t"); CGraphNode s = mgraph.CreateGraphNode <CGraphNode>("s"); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, y, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(t, z, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(x, t, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(y, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(y, z, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(z, x, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(z, s, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(s, t, GraphType.GT_DIRECTED); mgraph.AddGraphEdge <CGraphEdge, CGraphNode>(s, y, GraphType.GT_DIRECTED); // 2. Associate weights with the edges of the graph CGraphQueryInfo <int, int, int> weights = new CGraphQueryInfo <int, int, int>(mgraph, 255); weights.CreateInfo(y, x, -3); weights.CreateInfo(x, t, -2); weights.CreateInfo(t, x, 5); weights.CreateInfo(z, x, 7); weights.CreateInfo(y, z, 9); weights.CreateInfo(t, y, 8); weights.CreateInfo(t, z, -4); weights.CreateInfo(s, t, 6); weights.CreateInfo(s, y, 7); weights.CreateInfo(z, s, 2); mgraph.RegisterGraphPrinter(new CGraphVizPrinter(mgraph)); // The graph uses the registered printers to print the graph to the specified output mgraph.Generate(@"D:\MyPrivateWork\MyApps\MyApplications\EDUFLEX\GraphLibrary\TestSerialization\bin\Debug\test.dot", true); BinaryFormatter saver = new BinaryFormatter(); XmlSerializer xmlsaver = new XmlSerializer(typeof(CGraph)); using (Stream stream = new FileStream("graph.g", FileMode.Create, FileAccess.Write)) { saver.Serialize(stream, mgraph); } CGraph deserializedGraph; using (Stream stream = new FileStream("graph.g", FileMode.Open, FileAccess.Read)) { deserializedGraph = (CGraph)saver.Deserialize(stream); } deserializedGraph.RegisterGraphPrinter(new CGraphVizPrinter(mgraph)); // The graph uses the registered printers to print the graph to the specified output deserializedGraph.Generate(@"D:\MyPrivateWork\MyApps\MyApplications\EDUFLEX\GraphLibrary\TestSerialization\bin\Debug\regentest.dot", true); using (Stream stream = new FileStream("graph.xml", FileMode.Create, FileAccess.Write)) { xmlsaver.Serialize(stream, mgraph); } }