MathGroup Archive 2008

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

Search the Archive

Re: Re: changing style of vertices for ShowGraph with Combinatorica


It's not surprising that no edges are labelled in the first example  
for two reasons.  First, the custom definition of  
EdgeRenderingFunction overrides the setting for EdgeLabeling, as Carl  
Woll pointed out.  Second, the graph generated by Cycle[3] doesn't  
specify any labels for the edges.  Unless specific edge labels are  
given, even the default definition of EdgeRenderingFunction doesn't do  
anything, as the following example illustrates.

GraphPlot[{1 -> 2, 2 -> 3, 3 -> 1},
  VertexLabeling -> True,
  EdgeLabeling -> True
  ]

In my second example, I deliberately specified labels for the edges  
and gave a custom definition for EdgeRenderingFunction which would  
draw the labels over the middle of the edge.  What was surprising, in  
this case, was that the edge labels weren't being passed in as the  
third argument.  Hence my comment about it possibly being a bug.

On 9 Mar 2008, at 10:01, Murray Eisenberg wrote:

> The first example profered shows precisely part of the difficulty:  No
> edges are labeled!
>
> J. McKenzie Alexander wrote:
>> Setting the option VertexLabeling->True has no effect when a custom
>> definition is provided for VertexRenderingFunction, as VertexLabeling
>> only affects how the default rendering function draws the  
>> vertices.  If
>> you want vertex labels provided you need to include that in the
>> definition of the custom rendering function.
>>
>> Look up the documentation for VertexRenderingFunction and
>> EdgeRenderingFunction to see what additional arguments are  
>> provided. The
>> first argument for VertexRenderingFunction is the position of the
>> vertex. The second argument is the label.  So the following works:
>>
>> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True,
>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &),
>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],  
>> Yellow,
>>     Disk[#1, 0.04], Black, Text[#2, #1]} &)]
>>
>> You can drop the option settings for VertexLabeling and  
>> EdgeLabeling and
>> get the same effect.
>>
>> As for whether GraphPlot plays well with the Combinatorica graph
>> structure, it does handle vertex labels correctly but not edge  
>> labels,
>> as the following example illustrates.  I was personally surprised to
>> find that the edge labels were not passed to  
>> EdgeRenderingFunction.  I
>> think this might be a bug.
>>
>> GraphPlot[
>> Graph[{{{1, 2}, EdgeLabel -> "e1"}, {{2, 3}, EdgeLabel -> "e2"},  
>> {{3, 1},
>>    EdgeLabel -> "e3"}},
>>  {{{-0.5, 0.866}, VertexLabel -> "a"},
>>   {{-0.5, -0.866}, VertexLabel -> "b"},
>>   {{1., 0}, VertexLabel -> "c"}}],
>> EdgeRenderingFunction -> ({Black, Line[#1],
>>     Text[#3, Mean[#1]]
>>     } &),
>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}],  
>> Yellow,
>>     Disk[#1, 0.04], Black, Text[#2, #1]} &)]
>>
>> Cheers,
>>
>> Jason
>>

Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm


  • Prev by Date: Re: Error in Interpolation of multi-d datas
  • Next by Date: Re: Apply function to parts of a list
  • Previous by thread: Re: changing style of vertices for ShowGraph with Combinatorica
  • Next by thread: Re: Re: changing style of vertices for ShowGraph