Re: Re: Label vertices in Graph to display with GraphPlot

*To*: mathgroup at smc.vnet.net*Subject*: [mg87316] Re: [mg87276] Re: [mg87213] Label vertices in Graph to display with GraphPlot*From*: "J. McKenzie Alexander" <jalex at lse.ac.uk>*Date*: Mon, 7 Apr 2008 05:18:55 -0400 (EDT)*References*: <200804040758.CAA03960@smc.vnet.net> <200804061043.GAA14476@smc.vnet.net>

What was the problem with the documentation? The documentation for VertexRenderingFunction has the following as the first entry under "More Information": VertexRenderingFunction->f specifies that each vertex should be rendered with the graphics primitives given by f[rk,vk], where rk is the coordinate position where the vertex is being placed, and vk is its name. On 6 Apr 2008, at 11:43, Murray Eisenberg wrote: > At last I figured it out. (And no thanks to the documentation.) > > Here's a simple example of using non-default vertex labels in a > GraphPlot display with a graph created by a GraphPlot function: > > <<Combinatorica` > > labels = {"a", "b", "c", "d"}; > GraphPlot[Wheel[4], Method -> None, > VertexRenderingFunction -> > ({EdgeForm[{Brown}], Yellow, Disk[#1, 0.05], > Black, Text[labels[[#2]], #1]} &), > BaseStyle -> {FontSize -> 16}] > > The "secret" is in the meaning of the slot argument #2 to Text within > the VertexRenderingFunction. > > Murray Eisenberg wrote: >> I'm using some Combinatorica functions to create graphs where I do >> not >> specify individually the vertices -- and hence do not individually >> specify the vertex labels I want, e.g.: >> >> g = RotateVertices[Cycle[5], \[Pi]/10]; g = AddEdge[g, {2, 5}]; >> g = SetGraphOptions[g, VertexLabel -> Characters["abcde"]]; >> >> If I use Combinatorica`ShowGraph, then I'll see the vertex labels: >> >> ShowGraph[g] >> >> However, if I use Mathematica 6's kernel function GraphPlot, I >> don't see >> these individual labels, but rather the entire list {a,b,c,d,e} of >> labels at each vertex! >> >> GraphPlot[g,Method->None,VertexRenderingFunction->(Text[#2,#1]&) >> >> How do I coerce GraphPlot to reproduce the behavior of ShowGraph, so >> that it labels the individual vertices with a, b, c, d, e? >> >> (The interaction between Combintorica's graph-creating functions, >> on the >> one hand, and GraphPlot, on the other hand, remains mysterious and >> severely underdocumented for me. >> >> It seems there's a clear attempt to migrate display of graphs to the >> kernel function GraphPlot and thereby discourage use of ShowGraph, >> yet >> in almost everything I've attempted so far, GraphPlot does not so >> readily or gracefully reproduce the functionality of Combinatorica'a >> ShowGraph. This is most especially the case as it affects relative >> newcomers to Mathematica like my students.) > > -- > 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 >

**References**:**Label vertices in Graph to display with GraphPlot***From:*Murray Eisenberg <murray@math.umass.edu>

**Re: Label vertices in Graph to display with GraphPlot***From:*Murray Eisenberg <murray@math.umass.edu>