Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Nodes overlap in SpringLayout (Read 4423 times)
abereznyi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 22nd, 2010
Nodes overlap in SpringLayout
Mar 22nd, 2010 at 3:47pm
Print Post  
I set my nodes size to about 200 by 60, as I want to show some content in them.

I use SpringLayout Arrange() and then Diagram ResizeToFitItems() for layout but I can't make it to prevent nodes from overlapping.

Is there a way to make sure that nodes do not overlap after  SpringLayout Arrange() is called?
  

&&Thanks,&&Alex
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes overlap in SpringLayout
Reply #1 - Mar 22nd, 2010 at 4:25pm
Print Post  
The following settings seem to work fine for such nodes in my test:

Code
Select All
var sl = new SpringLayout();
sl.NodeDistance = 200;
sl.MinimizeCrossings = true;
sl.RepulsionFactor *= 100;
sl.Arrange(diagram); 



Please send a sample diagram to support@mindfusion.eu if you still get bad results.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
abereznyi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 22nd, 2010
Re: Nodes overlap in SpringLayout
Reply #2 - Mar 22nd, 2010 at 8:27pm
Print Post  
sl.RepulsionFactor is 0 and multiplying it by any factor is still 0, so nothing changes.

I tried to set RepulsionFactor to numbers like +-100, +-50, +-200, +-10, +-1 etc.
The node overlap is always much worse than with default value RepulsionFactor=0.

Setting EnableClusters = true improves layout some,
but I still can't get rid of node overlap...

  

&&Thanks,&&Alex
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes overlap in SpringLayout
Reply #3 - Mar 23rd, 2010 at 9:31am
Print Post  
This is what I get with a small test graph:



If you need to arrange larger and/or denser graphs, you will have to set a larger IterationCount.

In any case, this layout class does nothing to prevent overlapping, but just simulates some repulsion and spring forces. You might try using AnnealLayout instead - it creates similar results, but you have more control over criteria such as overlapping nodes and links through the various cost properties.

Stoyan
  
Back to top
 
IP Logged
 
abereznyi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 22nd, 2010
Re: Nodes overlap in SpringLayout
Reply #4 - Mar 23rd, 2010 at 7:39pm
Print Post  
Yes AnnealLayout is much nicer, but it's VERY slow.

I make diagrams with 25-50 nodes and it can go for 10 sec or more on high-end machine.

Also it occasionally put all the nodes in one narrow horizontal strip at the top  of the diagram right on top of each other - I suspect there is some bug there.

I designed a compromise by using both layouts with AnnealLayout  running with very few iterations to correct shortcomings of SpringLayout:

           var sl = new SpringLayout
                        {
                            NodeDistance = 200,
                            MinimizeCrossings = true,
                            RepulsionFactor = 0,
                            IterationCount = 500,
                            EnableClusters = true,
                            Anchoring = Anchoring.Reassign
                        };
           sl.Arrange(diagram);

           var al = new AnnealLayout
                        {
                            Anchoring = Anchoring.Reassign,
                            BoundaryFactor = 100000,
                            CrossingLinksCost = 300000,
                            DistributionFactor = 100000,
                            KeepGroupLayout = false,
                            IterationsPerStage = 5,
                            LinkLengthFactor = 0.10, // larger makes shorter links
                            NodeLinkCrossingCost = 250000,
                            NodeLinkDistFactor = 500000,
                            Randomize = false,
                            Stages = 10
                        };

           al.Arrange(diagram);
           diagram.ResizeToFitItems(50);

I do add a few nodes by clicking my button on my control node, which connects one or more new nodes with current node.

Is there a way to keep layout as close as possible to the layout before adding a node or two?
All nodes often end up in completely different places which is hard for users to follow.

  

&&Thanks,&&Alex
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes overlap in SpringLayout
Reply #5 - Mar 23rd, 2010 at 8:50pm
Print Post  
Try to initially place the new node at the median position of its neighbor nodes if they are more than one, and run AnnealLayout with lower InitialTemperature value for just a few stages. If the new node has one neighbor, move it somewhere near the already arranged neighbor. If the new node is not connected at all to other nodes, place it somewhere outside the union of all nodes rectangles.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes overlap in SpringLayout
Reply #6 - Mar 24th, 2010 at 9:45am
Print Post  
We have ported a SpringLayout feature from the WinForms version that could help for that:
https://mindfusion.eu/_beta/diaglite14_spring.zip

Now when you need to add only a few nodes to the layout, you can set node.LayoutTraits[SpringLayoutTraits.Frozen] = true for the already arranged nodes. The layout method keeps such nodes where they are, but still considers the forces they exert in the simulated system, so the newly added nodes should be placed at a suitable position in the layout. Then you might run just a few additional iterations with the Frozen flag removed to adjust the positions of nodes adjacent to the newly added ones.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
abereznyi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 22nd, 2010
Re: Nodes overlap in SpringLayout
Reply #7 - Mar 25th, 2010 at 3:02pm
Print Post  
I tried SpringLayoutTraits.Frozen, and it seems to improve layout a bit,
but this beta version has a problem: all images inside my control nodes and all its child controls are not visible, so I'll have to wait until it's fixed.
  

&&Thanks,&&Alex
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Nodes overlap in SpringLayout
Reply #8 - Mar 25th, 2010 at 3:06pm
Print Post  
Do you mean the images disappear from user-controls hosted in ControlNodes?
  
Back to top
 
IP Logged
 
abereznyi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Feb 22nd, 2010
Re: Nodes overlap in SpringLayout
Reply #9 - Mar 25th, 2010 at 3:29pm
Print Post  
Sorry my bad, I take it back:  it was my bug.

http://mindfusion.eu/Forum/Forum/images/smiley.gif
  

&&Thanks,&&Alex
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint