About edge routing

Feb 21, 2012 at 1:22 AM

I'm working on a app for Semantic Web. In current version of the app, the FOAF(www.foaf-project.org) schema is processed into nearly 80 nodes and 80 edges.

Then the performance becomes bad. I debugged and found that the main problem is in route(). In fact the problem is in piecewiseLinearCurve method. At start, piecewiseLinearCurve execution will cost nearly 45 seconds. I tried to optimize, but the cost is still 12-15 seconds. Then I use asynchronous Task(SL5), but it worked like synchronously, i don't know why...

At last i simplified route() -- delete the calls of piecewiseLinearCurve, and only uses the "finally" code block. So the new method becomes like:

private void route() {
   foreach ( var edge in Graph.Edges ) {
   List<Point2D> points = new List<Point2D>
   {
      edge.Src.Data.CenterPoint(),
      edge.Dst.Data.CenterPoint(),
   };

   // Replace center points of source and destination nodes by port points.
   var srcPort = edge.Src.Data.GetShapePort( points[1] );
   var dstPort = edge.Dst.Data.GetShapePort( points[points.Count - 2] );
   points[0] = srcPort;
   points[points.Count - 1] = dstPort;

   if ( edge.Data.IsRevert )
      points.Reverse();

   edge.Data.Points.Clear();
   foreach ( var p in points )
   edge.Data.Points.Add( p );

   // clear cache
   points.Clear();
}
}

 

The result is very good. And the only defect is that there is no curve while drawing edges.

If no one can optimize piecewiseLinearCurve method, or the main job is to let the application work first, i think the reduced code  is a solution.

I hope the idea of temporary solution can help someone. ^_^