Re: Re: Re: EdgeRenderingFunction to
- To: mathgroup at smc.vnet.net
- Subject: [mg87867] Re: [mg87835] Re: [mg87670] Re: [mg87549] EdgeRenderingFunction to
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 19 Apr 2008 03:32:30 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200804141914.m3EJEAKH027602@rcf1537-4.math.umass.edu> <200804150952.FAA25081@smc.vnet.net> <200804180640.CAA12631@smc.vnet.net>
- Reply-to: murray at math.umass.edu
Sorry about the mistake: Using characters as vertex labels here DOES work. (I had forgotten to revert to the names that Carl Woll used for the utility functions when I tried to evaluate the second input expression shown below.) But with a "catch": For this example, the edge labels of two of the edges are written to the same location, in the middle of the "X" inside the square, so that you see only one of them. Unfortunately, the ruse of including the Method->"HighDimensionalEmbedding" and then manually dragging vertices around so as to reveal the hidden vertex is not available: the VertexCoordinateRules option is not allowed here. 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]] > > > 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
- References:
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot
- From: Carl Woll <carlw@wolfram.com>
- Re: Re: EdgeRenderingFunction to produce edge
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: EdgeRenderingFunction to produce edge labels in GraphPlot