EdgeRenderingFunction to produce edge labels in GraphPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg87549] EdgeRenderingFunction to produce edge labels in GraphPlot
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 12 Apr 2008 07:03:16 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- Reply-to: murray at math.umass.edu
I'm having trouble fathoming from the documentation how
EdgeRenderingFunction works. In a display produced by GraphPlot,
applied to a graph that's a Graph object created with Combinatorica, I
want to be able to put distinct labels on the edges.
For example, take something very simple:
g = Cycle[3];
I'd like to put labels "a", "b", "c" on the three {1,2}, {2,3}, {3,1},
respectively.
Here's what I tried finally:
labels = Characters["abc"];
edgeLabelFunction[{u_, v_}] :=
labels[[First@Flatten@Position[Edges[Cycle[3]], {u, v}]]]
offset={0.05,0.05}; (* to move labels away from edges *)
GraphPlot[g, Method -> None,
EdgeRenderingFunction -> ({
Line[#1],
Inset[edgeLabelFunction[#2], Mean[#1] + offset]
]} &)
]
This does not work. How, exactly, do I index into the list of edges...
Edges[g]
{{1,2},{2,3},{1,3}}
.. so as to select the labels. From the reference page on
EdgeRenderingFunction, it seems to me that argument #2 is supposed to be
the length 2 list {u,v} of vertices with which the edge is incident.
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
- Follow-Ups:
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot
- From: Carl Woll <carlw@wolfram.com>
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot