none
How to set a bi-direction edge-- edge with arrows on both ends. RRS feed

  • Question

  • Please teach me how to set a bi-direction edge-- edge with arrows on both ends.

    Thanks

    Leo

    Wednesday, August 22, 2012 4:11 PM

Answers

All replies

  • edge.Attr.ArrowheadAtSource = ArrowStyle.Normal;

    Thanks,


    Lev Nachmanson

    • Marked as answer by Lev Nachmanson Thursday, August 23, 2012 5:58 PM
    • Unmarked as answer by yuxuzi Wednesday, August 29, 2012 8:50 PM
    Thursday, August 23, 2012 5:58 PM
  •  

    Hi, Thanks for your reply. However I run into an "Object reference not set to an instance of an object" error in the sentence 

           viewer.Graph = graph;

     Thanks again

    System.Windows.Forms.Form form = new System.Windows.Forms.Form();

                //create a viewer object 
                Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
                //create a graph object 
                Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
                //create the graph content 

                graph.AddEdge("1", "2");

                graph.AddEdge("1", "3");
                graph.AddEdge("1", "4");


                graph.AddEdge("2", "3");
                graph.AddEdge("2", "4");


                graph.AddEdge("3", "4");


          graph.Edges.First().Attr.ArrowheadAtSource = ArrowStyle.Normal;
                graph.FindNode("1").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
                graph.FindNode("2").Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;
                Microsoft.Msagl.Drawing.Node c = graph.FindNode("3");
                c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.PaleGreen;
                c.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;
                graph.Attr.NodeSeparation *= 4;
                graph.Attr.LayerSeparation /= 2;
                //bind the graph to the viewer 
            viewer.Graph = graph;
                //associate the viewer with the form 
                form.SuspendLayout();
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                form.Controls.Add(viewer);
                form.ResumeLayout();
                //show the form 
                form.ShowDialog();

                                                        
    Wednesday, August 29, 2012 8:54 PM
  • What object is null?

    Lev Nachmanson

    Thursday, August 30, 2012 5:42 AM
  • To be more clear :

    graph.AddEdge("B", "C").Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.Normal;

    Sunday, March 8, 2020 11:25 AM