none
Adding an edge that doesn't affect the layout? RRS feed

  • Question

  • Scenario

    1. Simple 3-level graph

                g.AddEdge("1a", "2a");
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");

                //g.AddEdge("4c", "2a"); // how to add an edge that doesn't affect the existing layout?

    2. I want to add edge 4c-2a to the graph without changing the layout.

    Questions

    1. How can I add an edge to a graph without changing the layout?

    2. What is the purpose of the e3.EdgeAttr.Weight property?

     

    Michael Herman (Toronto)


    Xpert Search Agents for Microsoft web sites: http://www.parallelspace.net/MicrodeX
    Wednesday, April 14, 2010 1:42 PM

Answers

  • Before adding edge 4c->2a you had a tree. After adding the edge you created a cycle. It is possible to check programmatically that a cycle is created and flipping the edge.

    In general the Sugiyma layout is not very stable. Changing the nodes order in the graph or adding an edge can change it dramatically.


    Lev Nachmanson
    Friday, April 16, 2010 4:29 PM

All replies

  • Every edge of the graph influences the final layout.  If you just want to have some data associated with the graph objects use field UserData. If EdgeAttr.Weight is increased the layout algorithm will try to keep this edge shorter.

    Thanks,

    Lev

     


    Lev Nachmanson
    Wednesday, April 14, 2010 5:21 PM
  • I want to have the extra edge drawn (to show a relationship between the 2 nodes) ...but I don't want it to have a drastic effect on the layout (which is what is happening now).

    Setting Weight to 100 on the important edges and setting the Weight of the extra edge to 1 doesn't seem to affect the layout very much.

    Questions

    1. What is the valid/recommended value range for Weights?

    2. What is the effect of a small Weight?  ...specifically, a Weight =0 and Weight = 1?

    3. What is the effect of a large Weight? ...what is considered a large Weight?

    4. What is the default value for a Weight?

    p.s. I'm prototyping using GLEE.

     


    Xpert Search Agents for Microsoft web sites: http://www.parallelspace.net/MicrodeX
    Wednesday, April 14, 2010 6:09 PM
  • FYI: adding a dummy node for the extra edge didn't help ..the layout still changed drastically.

    edge = g.AddEdge("4c", "dummy"); // how to add an edge that doesn't affect the existing layout?
    edge = g.AddEdge("dummy", "2a"); // how to add an edge that doesn't affect the existing layout?

     

     


    Xpert Search Agents for Microsoft web sites: http://www.parallelspace.net/MicrodeX
    Wednesday, April 14, 2010 6:38 PM
  • I got it. You don't want to break the existing layers. Please you the following code

                g.AddEdge("1a", "2a").Attr.Weight=2;
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");
                var e=g.AddEdge("2a", "4c"); // reverted edge
                e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;

     

     


    Lev Nachmanson
    Wednesday, April 14, 2010 11:25 PM
  • I got it. You don't want to break the existing layers. Please you the following code

                g.AddEdge("1a", "2a").Attr.Weight=2;
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");
                var e=g.AddEdge("2a", "4c"); // reverted edge
                e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;

     

     


    Lev Nachmanson
    Wednesday, April 14, 2010 11:25 PM
  • I got it. You don't want to break the existing layers. Please use the following code

                g.AddEdge("1a", "2a").Attr.Weight=2;
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");
                var e=g.AddEdge("2a", "4c"); // reverted edge
                e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;


    Lev Nachmanson
    Wednesday, April 14, 2010 11:27 PM
  • I got it. You don't want to break the existing layers. Please you the following code

                g.AddEdge("1a", "2a").Attr.Weight=2;
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");
                var e=g.AddEdge("2a", "4c"); // reverted edge
                e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;

     

     


    Lev Nachmanson
    Wednesday, April 14, 2010 11:27 PM
  • I got it. You don't want to break the existing layers. Please you the following code

                g.AddEdge("1a", "2a").Attr.Weight=2;
                g.AddEdge("1a", "2b");
                g.AddEdge("1a", "2c");

                g.AddEdge("2c", "3a");
                g.AddEdge("2c", "3b");
                g.AddEdge("2c", "3c");

                g.AddEdge("3c", "4a");
                g.AddEdge("3c", "4b");
                g.AddEdge("3c", "4c");
                var e=g.AddEdge("2a", "4c"); // reverted edge
                e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
                e.Attr.ArrowheadAtTarget = ArrowStyle.None;

     

     


    Lev Nachmanson
    Wednesday, April 14, 2010 11:29 PM
  • I think I understand your approach ...which works OK for an interactive program (where the human mind can detect the layout issue and flip the edge around). 

    It's not clear how to detect this automatically in code for an arbitrary "relationship" edge?


    Xpert Search Agents for Microsoft web sites: http://www.parallelspace.net/MicrodeX
    Friday, April 16, 2010 2:17 PM
  • Before adding edge 4c->2a you had a tree. After adding the edge you created a cycle. It is possible to check programmatically that a cycle is created and flipping the edge.

    In general the Sugiyma layout is not very stable. Changing the nodes order in the graph or adding an edge can change it dramatically.


    Lev Nachmanson
    Friday, April 16, 2010 4:29 PM