Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Speed of adding graph elements and layout (Read 4303 times)
thejimster
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Speed of adding graph elements and layout
Sep 23rd, 2015 at 8:40am
Print Post  
I'm try to work out what my expectations should be for speed of operation of the diagram component.

Base on forum help I am doing the following to construct my graph:
Add all containers/nodes
Add all links
Layout all containers
Layout diagram
Route all links

I'm using a LayeredLayout (because I think this best fits the data) with the following properties:

LayeredLayout layout = new LayeredLayout();
layout.Orientation = MindFusion.Diagramming.Wpf.Layout.Orientation.Vertical;
layout.Anchoring = Anchoring.Keep;
layout.LinkType = LayeredLayoutLinkType.Cascading;
layout.StableSort = true;
layout.LayerDistance = 50;
layout.NodeDistance = 50;
layout.IgnoreNodeSize = false;
layout.EnableParallelism = true;

I've used a stopwatch to time the various phases, which are as follows:

==== Adding [555] Nodes: 00:00:00.2420000
==== Adding [785] Connections: 00:00:02.5310000
==== Layout Containers: 00:00:01.2920000
==== Layout Main: 00:00:11.9470000
==== Reroute Connections: 00:00:00.2870000
==== Total: 00:00:16.3050000

So, total time is about 16 secs, with the worst offenders being adding connections, and main diagram layout.

Is there anything I can do to speed this up?
I can code fragments if that would help pinpoint performance issues.

Thanks,

Jim.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Speed of adding graph elements and layout
Reply #1 - Sep 23rd, 2015 at 9:44am
Print Post  
Hi,

To improve speed of populating the diagram, use BeginInit/EndInit methods and disable ValidityChecks:
http://mindfusion.eu/Forum/YaBB.pl?num=1268995278/1#1

Also check if you aren't using some of the properties mentioned here:
http://mindfusion.eu/Forum/YaBB.pl?num=1358507496

For better LayeredLayout performance, try calling it with EnforceLinkFlow property enabled. Try also disabling the GrowToFit property and calling diagram.ResizeToTitItems only after all Arrange calls; this will avoid some iterations over all diagram elements and calculating union of their bounding rectangles done by each Arrange call for GrowToFit.

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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: Speed of adding graph elements and layout
Reply #2 - Sep 23rd, 2015 at 10:44am
Print Post  
Thanks Stoyan.

I have made the changes to use BeginInit/EndInit and turned off validity checking.  Unfortunately, this has made no noticeable difference to speed of adding diagram elements.

Changing GrowToFit has also made no noticeable difference.

Turning on EnforceLinkFlow causes an ArgumentOutOfRange exception during the layout phase:

>      mscorlib.dll!System.Collections.CollectionBase.System.Collections.IList.get_Item
(int index) Line 106      C#
     MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.PointCollection.this[int].get(int index)      Unknown
     MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Layout.LayeredLayout.K
L(MindFusion.Diagramming.Wpf.Diagram Q, System.Collections.IEnumerable V)      Unknown
     MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Layout.Layout.Arrange(
MindFusion.Diagramming.Wpf.Diagram diagram, MindFusion.Diagramming.Wpf.DiagramItemCollection items)      Unknown
     MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Layout.Layout.Arrange(
MindFusion.Diagramming.Wpf.Diagram diagram)      Unknown

Thanks,

Jim.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Speed of adding graph elements and layout
Reply #3 - Sep 23rd, 2015 at 12:46pm
Print Post  
I was able to reproduce this in some code that processes repeating links between same nodes. It happens if AutoRoute is enabled, so for time being you could disable auto-routing before arranging:

Code
Select All
foreach (var l in diagram.Links)
	l.AutoRoute = false;
// arrange 



If it's not caused by AutoRoute, please attach saved diagram file from just before you run layout code.

Auto-routing could be slowing down node and link creation code too, you could defer enabling it for links until the diagram is fully arranged, and then enclose the assignment between LinkRouter.Supend and Resume calls to avoid re-routing the links:

Code
Select All
diagram.LinkRouter.Suspend();
foreach (var l in diagram.Links)
	l.AutoRoute = true;
diagram.LinkRouter.Resume(false); 



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


I Love MindFusion!

Posts: 10
Joined: Sep 18th, 2015
Re: Speed of adding graph elements and layout
Reply #4 - Sep 23rd, 2015 at 1:43pm
Print Post  
Thanks Stoyan.

Turning off AutoRoute has enabled me to turn on EnforceLinkFlow.  With these two modifications in place I get results of:
==== Adding [551] Nodes: 00:00:00.2550000
==== Adding [781] Connections: 00:00:02.8520000
==== Layout Containers: 00:00:01.2230000
==== Layout Main: 00:00:00.5790000
==== Reroute Connections: 00:00:00.3050000
==== Total: 00:00:05.2400000

If I also Suspend/Resume LinkRouter around populating the graph:
==== Adding [551] Nodes: 00:00:00.3030000
==== Adding [781] Connections: 00:00:01.6480000
==== Layout Containers: 00:00:01.0870000
==== Layout Main: 00:00:00.5400000
==== Reroute Connections: 00:00:00.3470000
==== Total: 00:00:03.9550000

That's a pretty good improvement!

Is there any thing else that I can do to make further improvements?

Thanks,
Jim.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Speed of adding graph elements and layout
Reply #5 - Sep 23rd, 2015 at 1:55pm
Print Post  
You could assign smaller value to LayeredLayout.SwapPairsIterations property than default 5, but then you'll be getting more link crossings.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint