MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

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
> 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

  • Prev by Date: Re: Re: mathematica on macbook... hangs on 5-4
  • Next by Date: Re: CreateDialog Pecularity
  • Previous by thread: Re: Label vertices in Graph to display with GraphPlot
  • Next by thread: Re: Re: Label vertices in Graph to display with