Named Edges

Oct 21, 2010 at 12:56 PM


Can I give names  for graph edges?

Thank you!

Oct 22, 2010 at 7:57 AM

If you only want to have a property "Name" without drawing thease names near arrows you can look into DrawingGraph.cs.

You will see there the folowing:

public partial class DrawingGraph : GenericGraphT<DrawingGraph.Node, DrawingGraph.Edge, string, object>

The last type parameter is type of data that can be attached to edge ( myEdge.Data = someData )

If you change it from object to string you can use it as Name of edge.

Also you can define class for example:

public class MyEdgeData
   public string Name {get;set;}
   public string Descr {get;set;}
   public DateTime Somedate {get;set;}

And use it as edge data:

public partial class DrawingGraph : GenericGraphT<DrawingGraph.Node, DrawingGraph.Edge, string, MyEdgeData>
But drawing text along arrows now is not supported. If you need this feature and have any ideas then you can join GraphLight project.


Oct 22, 2010 at 11:42 AM


Then  I have a question.

In yuor project, edges drown using the "EdgesControl.xaml"? That is one edge object  == one "EdgesControl".

But I tried fix the "EdgesControl.xaml".

I tried to add TextBlock to "EdgesControl.xaml" and as a result of my fix I have one text for all edges in graph.

Could you tell me the name of the file which the adges created and added to the GraphControl?

Sorry for my Bad English.

Oct 22, 2010 at 12:52 PM

EdgeControl is used as DataTemplate for GraphItemsControl. So instances of EdgeControl are created inside ItemsControl which is framework class.

Each EdgeControl is a Grid without background. It contains some Pathes and Points which shapes and locations defined by coordinates in DrawingGraph.Edge.Points.

GraphControl contains many layers. Each layer contains one node or one edge. So if you just place TextBlock in EdgeControl.xaml you will get many TextBlocks in top left corner placed one over another.

The solution is to properly align your TextBlock along edge. This alignment should be done using data from DrawingGraph.Edge.

Oct 22, 2010 at 1:39 PM

Maybe this project will help you

Oct 24, 2010 at 11:30 AM

Thank you!

I solved my problem. I used ToolTipServices for view adges name.

But I plan to do this with TextOnAPath

Mar 5, 2011 at 9:17 PM

Has anyone been able to accomplish this and is able to provide some sample code? I am trying to use graph light for a school project and we are having A LOT of difficulty with just putting text on an edge. We don't plan on moving the edges around so we don't necessarily need the text to follow the movement of the edge.

Thanks in advice!

Mar 29, 2011 at 1:48 PM


I've tried to use TextOnAPath but i couldn't make it work.