How to render graph using MSAGL

Topics: graph
Aug 3, 2012 at 4:25 PM

I have installed and added reference to MSAGL Library and QuickGraph Library

Microsoft.Msagl

Microsoft.Msagl.Drawing

Microsoft.Msagl.Graphviewergdi

QuickGraph

QuickGraph.data

QuickGraph.graphviz

QuickGraph.serialization.  

these libraries are automatically added using nuget.

I have following code and i want to display 'graph1' into microsoft's  AGL GraphViewer.

Please advice what libraries other then above I need to add, Where I will find them and what code I need to write to be able to display graph in MSagl Viewer.

Regards

 

   AdjacencyGraph<string, Edge<string>> graph1 = new AdjacencyGraph<string, Edge<string>>(true);

            // Add some vertices to the graph
            graph1.AddVertex("A");
            graph1.AddVertex("B");
            graph1.AddVertex("C");

            // Create the edges
            Edge<string> a_b = new Edge<string>("A", "B");
            Edge<string> a_d = new Edge<string>("A", "D");
            Edge<string> b_a = new Edge<string>("B", "A");
            Edge<string> b_c = new Edge<string>("B", "C");
            Edge<string> b_e = new Edge<string>("B", "E");
        

            // Add the edges
            graph1.AddEdge(a_b);
            graph1.AddEdge(a_d);
            graph1.AddEdge(b_a);
            graph1.AddEdge(b_c);
            graph1.AddEdge(b_e);
            graph1.AddEdge(c_b);
     

            // Define some weights to the edges
            Dictionary<Edge<string>, double> edgeCost = new Dictionary<Edge<string>, double>(graph.EdgeCount);
            edgeCost.Add(a_b, 4);
            edgeCost.Add(a_d, 1);
            edgeCost.Add(b_a, 74);
            edgeCost.Add(b_c, 2);
            edgeCost.Add(b_e, 12);
            edgeCost.Add(c_b, 12);