Re: Re: Re: Re: changing
- To: mathgroup at smc.vnet.net
- Subject: [mg87034] Re: [mg87002] Re: [mg86341] Re: [mg86332] Re: [mg86270] changing
- From: Carl Woll <carlw at wolfram.com>
- Date: Sat, 29 Mar 2008 04:25:55 -0500 (EST)
- References: <200803070729.CAA19892@smc.vnet.net> <C63D1D41-0058-431D-A84D-4418E66DBF46@lse.ac.uk> <200803081044.FAA13587@smc.vnet.net> <200803090959.EAA12270@smc.vnet.net> <200803280818.DAA04866@smc.vnet.net>
Murray Eisenberg wrote: >But how do I get GraphPlot to use labels that _I_ specify, rather than >numbers -- when using a graph created with Combinatorica and without >having to directly specify the labels as part of the graph structure. > >For example: > > g=Cycle[6]; > > GraphPlot[g, > VertexLabeling->True,VertexRenderingFunction->(Text[...]&)] > >This sort of thing doesn't produce any vertex labels even if I first use >something like: > > g = SetGraphOptions[g, VertexLabel -> Characters["b,a,f,e,d,c"]]; > > The VertexLabel option can take Boolean values only. Perhaps you meant: g = SetVertexLabels[Cycle[6], {b,a,f,e,d,c}]; GraphPlot[g, VertexLabeling -> True] Carl Woll Wolfram Research >(Comment: The documentation about graph display is really atrociously >inadequate!) > >Carl Woll wrote: > > >>Murray Eisenberg wrote: >> >> >> >>>Yes, GraphPlot seems to permit making nice vertices (or edges), but then >>>the labeling -- either with a Graph object from Combinatorica or just >>>the kind of graph described by the GraphPlot reference page -- does not >>>seem to admit vertex labels or edge labels, at least so far as I can >>>see. For example, neither of the following displays either vertex >>>labels or edge labels: >>> >>> >>>GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True, >>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &), >>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], >>> Yellow, Disk[#1, 0.04]} &)] >>> >>>GraphPlot[{{v1 -> v2, "a"}, {v2 -> v3, "b"}, {v3 -> v1, "c"}}, >>> Method -> Automatic, VertexLabeling -> True, EdgeLabeling -> True, >>> EdgeRenderingFunction -> ({Black, Line[#1]} &), >>> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], >>> Yellow, Disk[#1, 0.04]} &)] >>> >>>On the other hand, if I remove he VertexRenderingFunction option, I do >>>see vertex labels on the default (yellow boxes) vertex shapes: >>> >>> >>> >>> >> From the help for VertexLabeling: >> >>"Any explicit setting for VertexRenderingFunction overrides the setting >>for VertexLabeling." >> >>Similarly for EdgeLabeling. >> >>If you want labels when using VertexRenderingFunction, you need to put >>them in explicitly in the VertexRenderingFunction rhs. The first example >>in the VertexRenderingFunction function page does this. >> >>If you want to recreate the default labeling inside >>VertexRenderingFunction, the following may help: >> >>VertexRenderingFunction -> (Text[ >> Framed[#2, {Background -> RGBColor[1, 1, .8], FrameStyle -> >>RGBColor[.94, .85, .36], FrameMargins -> Automatic}], #] &)] >> >>Carl Woll >>Wolfram Research >> >> >> >>> GraphPlot[{v1 -> v2, "a"}, {v2 -> v3, "b"}, {v3 -> v1, "c"}}, >>> Method -> Automatic, VertexLabeling -> True, >>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &)] >>> >>>GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True, >>> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &)] >>> >>>Of course this now defeats the purpose of using GraphPlot so as to get >>>exactly the kind of vertex shapes that VertexRenderingFunction, above, >>>provides. >>> >>>Similarly with EdgeRenderingFunction. >>> >>>The kernel function GraphPlot doesn't seem to mesh very well with >>>Combinatorica's graph functions. This all still seems only "half-baked". >>> >>> >>>J. McKenzie Alexander wrote: >>> >>> >>> >>> >>>>Take a look at GraphPlot, the graph rendering function that is built >>>>into the Mathematica kernel. I switched from using ShowGraph to >>>>GraphPlot after realising that it was (a) faster and (b) easier to >>>>customise. Here's what you want: >>>> >>>>GraphPlot[ >>>>Cycle[3], >>>>Method -> None, >>>>EdgeRenderingFunction -> ({Black, Line[#1]} &), >>>>VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], Yellow, >>>> Disk[#1, 0.04]} &) >>>>] >>>> >>>>You need to specify Method->None, otherwise GraphPlot will override the >>>>specified positions of the vertices in the graph and use its own default >>>>vertex positioning algorithm. >>>> >>>>VertexRenderingFunction is what you need to define in order to customise >>>>the appearance of the vertices. >>>> >>>>I provided a definition of EdgeRenderingFunction just so that the edges >>>>are rendered in the same way as ShowGraph. >>>> >>>>Cheers, >>>> >>>>Jason >>>> >>>>-- >>>>J. McKenzie Alexander >>>>Department of Philosophy, Logic and Scientific Method >>>>London School of Economics and Political Science >>>>Houghton Street, London WC2A 2AE >>>> >>>> >>>>On 7 Mar 2008, at 07:29, Murray Eisenberg wrote: >>>> >>>> >>>> >>>> >>>> >>>>>With Mathematica 6, I can change the default style (medium black disk) >>>>>for rendering the vertices of a Combinatorica Graph like this: >>>>> >>>>> Needs["Combinatorica`"] >>>>> >>>>> g = Cycle[3]; >>>>> ShowGraph[g, VertexStyle -> Disk[Large], VertexColor -> Red] >>>>> >>>>>But how can I, for example, change the vertex style so it is, say, a >>>>>large yellow disk with a thick red boundary? Or even just change it to >>>>>be a circle? I tried "obvious" things like the following, but they >>>>>cause errors: >>>>> >>>>> ShowGraph[g, VertexStyle -> Graphics[Circle[], ImageSize -> 20]] >>>>> >>>>>-- >>>>>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 >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>>Please access the attached hyperlink for an important electronic >>>>communications disclaimer: >>>>http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >> >> > > >
- References:
- changing style of vertices for ShowGraph with Combinatorica
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: changing style of vertices for ShowGraph with Combinatorica
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: changing style of vertices for ShowGraph
- From: Carl Woll <carlw@wolfram.com>
- Re: Re: Re: changing style of vertices
- From: Murray Eisenberg <murray@math.umass.edu>
- changing style of vertices for ShowGraph with Combinatorica