Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Displaying Large Graphs (Read 2347 times)
Gillsta
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Jul 30th, 2008
Displaying Large Graphs
Jul 30th, 2008 at 2:37pm
Print Post  
I'd like to be able to display graphs with around 2000 nodes and 4000 links. Are graphs of this size supported? 
If so what layouts and settings should I be using to reduce the initial load time?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Displaying Large Graphs
Reply #1 - Jul 31st, 2008 at 8:20am
Print Post  
The quickest way to create the items should look like this

Code
Select All
private void btnCreateItems_Click(object sender, EventArgs e)
{
	Random rnd = new Random();

	diagram.Bounds = new RectangleF(0, 0, 3300, 3300);
	diagram.RouteLinks = false;
	diagram.ValidityChecks = false;
	diagram.UndoManager.UndoEnabled = false;

	DateTime start = DateTime.Now;

	for (int i = 0; i < 2000; ++i)
	{
		diagram.Factory.CreateShapeNode(
			//(i / 50) * 15, (i % 50) * 15, 10, 10, Shapes.Rectangle);
			rnd.Next(3000), rnd.Next(3000), 10, 10, Shapes.Rectangle);
	}

	for (int i = 0; i < 4000; ++i)
	{
		diagram.Factory.CreateDiagramLink(
			diagram.Nodes[i % 2000], diagram.Nodes[rnd.Next(2000)]);
	}

	DateTime end = DateTime.Now;
	MessageBox.Show((end - start).ToString());
}
 



I'll check in awhile if some of our layout algorithms can arrange the items fast enough.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Displaying Large Graphs
Reply #2 - Jul 31st, 2008 at 8:25am
Print Post  
The method above completes for about a second if the Diagram is not displayed yet in a DiagramView, or for 6-7 seconds otherwise. So you might create the items in an off-screen Diagram object, and assign it to DiagramView.Diagram after that.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Displaying Large Graphs
Reply #3 - Jul 31st, 2008 at 11:07am
Print Post  
If your graph is a tree, you could use TreeLayout - it needed about 40 seconds to arrange the tree on my system.

If it's an arbitrary graph, you could use some of the iterative algorithms such as SpringLayout or GridLayout, but they will need at least five minutes to complete. For example you can use GridLayout like this:

Code
Select All
DateTime start = DateTime.Now;

// GridLayout uses link-routing internally
diagram.RoutingOptions.DontOptimizeLongRoutes = true;

GridLayout gl = new GridLayout();
gl.SplitGraph = false;
gl.StartNode = diagram.Nodes[0];
gl.EndNode = diagram.Nodes[1999];
gl.Iterations = 50;
gl.UseLongestPath = false;
gl.Arrange(diagram);

DateTime end = DateTime.Now;
MessageBox.Show((end - start).ToString());
 



Depending no the structure of your graphs, you could optimize the layout running time greatly. For example if a graph is partitioned into clusters, you could run a layout algorithm for each cluster independently, using the Arrange(DiagramItemCollection) methods of say SpringLayout or TreeLayout. Next, use the AttachTo method to attach all nodes from a cluster to the central node in a cluster, and run some layout algorithm using the KeepGroupLayout option, and passing only the clusters' central nodes to the Arrange(DiagramItemCollection) method.

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


I love YaBB 1G - SP1!

Posts: 2
Joined: Jul 30th, 2008
Re: Displaying Large Graphs
Reply #4 - Jul 31st, 2008 at 1:17pm
Print Post  
Thanks, that should help me get an initial display going much faster.

Would the use of lanes to constrain the optimisation be of any help?

I've been looking through the help and samples on lanes but would appreciate an example of how to use them.

As background I'm using Nodes to represent activities and links as the dependecies between activities. Each activity has a person assigned to perform it and I'd like to have all activities perfromed by the same person to be in their own lane.

I can see from the help how to add the Headers to represent each person but cannot work out how to specify that a Node should be assigned to a lane based on a person field.

Many thanks for you help.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Displaying Large Graphs
Reply #5 - Aug 1st, 2008 at 6:23am
Print Post  
Hi Peter,

The built-in lanes are just a background decoration. At this time you can't bind a node to a specific lane, or make the layout algorithms constrain nodes to a lane.

Having the diagram partitioned into lanes should help you lay out the items in a more timely manner. Assuming there are no links between items on different lanes (or you exclude them from the layout temporarily), you might use the MultipleGraphPlacement = Vertical option, which will arrange the subgraph associated with each person, and move it below the sub-graph of the previous person. Then you might calculate the union of all activities bounding rectangles, and use its Y and Height as coordinates for the lane. You might draw the lanes either by handling the DrawBackground event as in the SequenceDiagram sample, or by setting up the LaneGrid.

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