Edge position and edge label position

I'm using Graphviz as a library (C++). I create graph with agopen. Then I create nodes with agnode and edges with agedge. After gvLayout, how to get calculated coordinates for edges and edges labels? I only need edges position and edges label position. I can get calculated nodes position but not edges and edge labels.I will store this position information in my graph structure.

Two ways: Call gvRender

Two ways:

  • Call gvRender (gvc, G, "dot", NULL); This attaches all of the position attributes to the elements of the graph. Then if ep points to an edge, the calls agget(ep,"pos") and agget(ep,"lp") will return strings encoding the edge position and label position, respectively. The format of these strings is described at http://www.graphviz.org/content/attrs#ksplineType and http://www.graphviz.org/content/attrs#kpoint, respectively.
  • Access the data structures directly.Again, if ep is an Agedge_t*, ED_pos(ep) and ED_label(ep) will return pointers to structures of type splines and textlabel_t. For the label position, you can use ED_labep(ep)->pos. The splines structure is an array of beziers; normally only one is used. A bezier is a list of points describing a cubic B-spline. In addition, there is information of arrowheads and tails. For more information, see http://www.graphviz.org/doc/libguide/libguide.pdf, especially section 2.3.1.

Recent comments