Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SpringLayout (Read 4502 times)
Sabrina C.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 35
Joined: Dec 20th, 2012
SpringLayout
Aug 22nd, 2016 at 7:16am
Print Post  
Hi,

we're looking for a method to strengthen some links among some of the nodes when using the springlayout, so that some links are stronger than others to simulate a scenario where some nodes are already clustered.

Currently the only way is to provide additional transparent links among nodes belonging to the same cluster, but it is not a viable solution with a large number of nodes (because the number of links grows exponentially).

Is there any way to provide e different spring constant to a particular set of links to control the forces between nodes?

S.

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SpringLayout
Reply #1 - Aug 22nd, 2016 at 9:40am
Print Post  
Hi,

Try dividing link's Weight value by how much shorter you'd like it to be relatively to the layout's NodeDistance.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Sabrina C.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 35
Joined: Dec 20th, 2012
Re: SpringLayout
Reply #2 - Sep 19th, 2016 at 1:56pm
Print Post  
Hi,

we tried your solution, but it's hard to detect any effect on the layout of nodes. Probably there is something not setup in our implementation.


Can you post a working example where we can play with values (or with a slider) and appreciate changes in how nodes are attracted?

Thx, S.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SpringLayout
Reply #3 - Sep 19th, 2016 at 2:24pm
Print Post  
Hi,

SpringLayout.EnableClusters might override custom weights, are you using that property? You'll have to turn it off and set large enough Weight of inter-cluster links to get same effect.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Sabrina C.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 35
Joined: Dec 20th, 2012
Re: SpringLayout
Reply #4 - Nov 25th, 2016 at 3:49pm
Print Post  
I've tried with both the settings, but no luck. Any additional idea to use that weights?

One more important thing about the springlayout when used with a large number of nodes and links.

We know that the force-directed graphs are computationally intensive (maybe On3), but we need two things:

- a method to have some progress from the layout.Arrange because when launched it is blocking for the UI, so we need at least a way to know at which progress it is arrived before deciding to kill the layout process or the program

- a way to disable the UI update during the layout.beginArrange. When animating a springlayout, the update of the layout is a way too slow with respect to the layout.Arrange method, but we have the progress from the layout.beginArrange method


Is there a way to to put the spring layout computation on additional threads or doing some background computation and then put the graphical elements on the diagram as soon as the layout has process is terminated? It is really important for us when dealing with big node and link numbers. Or can you suggest a way to use the spinglayout just to compute the final positions of the elements in the fastest way?

Thanks Sabrina
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SpringLayout
Reply #5 - Nov 29th, 2016 at 7:30am
Print Post  
We'll add some flag to the iterative API to let you disable UI updates. That should also let you call it from a different thread.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SpringLayout
Reply #6 - Dec 1st, 2016 at 5:35pm
Print Post  
Since you mentioned clusters and complexity, you might try using CompositeLayout to reduce the number of node pairs for which forces are calculated. The time I got from two cases below are 00:01:42.2162241 vs 00:00:17.9842514. Running SpringLayout for the whole sample graph is O(power of 200), running CompositeLayout with SpringLayout on each partition is 20 * O(power of 10).

Code
Select All
void TestSpringLayout()
{
	var start = DateTime.Now;
	CreateClusters();
	var sl = new SpringLayout();
	sl.IterationCount = 50;
	sl.Arrange(diagram);
	Debug.WriteLine(DateTime.Now - start);

	start = DateTime.Now;
	var c = CreateClusters();
	var cl = new CompositeLayout();
	cl.PartitionMethod = PartitionMethod.Custom;
	cl.CustomPartition = c;
	cl.MasterLayout = sl;
	cl.SubgraphLayout = sl;
	cl.Arrange(diagram);
	Debug.WriteLine(DateTime.Now - start);
}

List<System.Collections.IEnumerable> CreateClusters()
{
	var clusters = new List<System.Collections.IEnumerable>();
	diagram.ClearAll();
	DiagramNode prev = null;
	for (int i = 0; i < 20; i++)
	{
		var c = CreateCluster(i);
		clusters.Add(c);
		if (prev != null)
			diagram.Factory.CreateDiagramLink(prev, c[0]);
		prev = c[0];
	}
	return clusters;
}

DiagramNodeCollection CreateCluster(int id)
{
	var nodes = new DiagramNodeCollection();
	for (int i = 0; i < 10; i++)
	{
		var node = diagram.Factory.CreateShapeNode(0, 0, 20, 20);
		nodes.Add(node);
	}
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			if (i != j)
				diagram.Factory.CreateDiagramLink(
					(DiagramNode)nodes[i], (DiagramNode)nodes[j]);
		}
	}
	return nodes;
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SpringLayout
Reply #7 - Dec 22nd, 2016 at 5:26pm
Print Post  
This build adds an async flag -
https://mindfusion.eu/_beta/wpfdiag342.zip

Set it to true to safely run iterations from a thread -
Code
Select All
var sl = new SpringLayout();
sl.BeginArrange(diagram, null);
sl.IterationCount = 50;
var t = new Thread(() =>
{
	sl.Iterate(0, 49, true);
	sl.EndArrange();
});
t.Start(); 



When it's true, the UI gets updated via Dispatcher.Invoke after last iteration. Meanwhile you can subscribe to layout.Progress notifications, receiving them in the worker thread.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint