Re: Re: EdgeRenderingFunction to produce edge

• To: mathgroup at smc.vnet.net
• Subject: [mg87871] Re: [mg87670] Re: [mg87549] EdgeRenderingFunction to produce edge
• From: Carl Woll <carlw at wolfram.com>
• Date: Sat, 19 Apr 2008 03:33:13 -0400 (EDT)
• References: <200804141914.m3EJEAKH027602@rcf1537-4.math.umass.edu> <200804150952.FAA25081@smc.vnet.net> <48082480.8010705@math.umass.edu>

```Murray Eisenberg wrote:

> I believe this method fails to preserve vertex coordinates from an
> original Combinatorica Graph[...] object in case one changes the
> vertex labels to, say, letters.  For example:
>
>   g = SetEdgeLabels[SetVertexLabels[Wheel[4], Characters["1234"]],
>    Characters["defabc"]];
>
>   GraphPlot[torules[g], EdgeLabeling -> True, VertexLabeling -> True,
>      VertexCoordinateRules -> getcoords[g]]
>
Yes, I made a mistake in the definition of getcoords. It should be:

getcoords[Graph[edges_, vertices_, ___]] := vertices[[All, 1]]

Carl Woll
Wolfram Research

>
> Carl Woll wrote:
>
>>
>> ... If you want to use my first method and maintain the vertex
>> locations, then you need to include that information in the call to
>> GraphPlot.
>>
>> Here is a function that creates the usual rule structure that
>> GraphPlot expects from a Combinatorica graph (with vertex and edge
>> labels):
>>
>> torules[Graph[edges_, vertices_, ___]] := Module[
>>     {vrules},
>>        vrules = DeleteCases[
>> vertices[[All,2 ;;]])],
>>         _ -> VertexLabel
>>     ];
>>     Replace[
>>         Transpose[{Rule @@@ (edges[[All,1]] /. vrules), EdgeLabel /.
>> edges[[All,2 ;;]]}],
>>         {a_, EdgeLabel} -> a,
>>         {1}
>>     ]
>> ]
>>
>> Here is a function that extracts coordinates from a Combinatorica graph:
>>
>> getcoords[Graph[edges_, vertices_, ___]] :=
>>
>> So, let's create a graph with edge and vertex labels:
>>
>> g = SetEdgeLabels[SetVertexLabels[Cycle[3], {a, b, c}], {x, y, z}];
>>
>> Now, we'll use GraphPlot to view the graph:
>>
>> GraphPlot[torules[g], EdgeLabeling->True, VertexLabeling->True,
>> VertexCoordinateRules->getcoords[g]]
>
>

```

• Prev by Date: Re: Re: Re: EdgeRenderingFunction to
• Next by Date: Re: Product command with matrices
• Previous by thread: Re: Re: Re: EdgeRenderingFunction to
• Next by thread: Re: EdgeRenderingFunction to produce edge labels in GraphPlot