Re: Re: EdgeRenderingFunction to produce edge
- To: mathgroup at smc.vnet.net
- Subject: [mg87835] Re: [mg87670] Re: [mg87549] EdgeRenderingFunction to produce edge
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 18 Apr 2008 02:40:45 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200804141914.m3EJEAKH027602@rcf1537-4.math.umass.edu> <200804150952.FAA25081@smc.vnet.net>
- Reply-to: murray at math.umass.edu
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]] 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[ > Thread[Range[Length[vertices]] -> (VertexLabel /. > 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_, ___]] := > Thread[Rule[Range[Length[vertices]], vertices[[All, 1]]]] > > 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]] -- 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: Re: Re: EdgeRenderingFunction to
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: Re: EdgeRenderingFunction to
- References:
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot
- From: Carl Woll <carlw@wolfram.com>
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot