Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: How do I use EdgeRenderingFunction in GraphPlot with one command

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89336] Re: How do I use EdgeRenderingFunction in GraphPlot with one command
  • From: mark mcclure <mcmcclur at unca.edu>
  • Date: Fri, 6 Jun 2008 06:46:40 -0400 (EDT)
  • References: <g1v167$23o$1@smc.vnet.net>

On Jun 1, 4:35 pm, Pavithra Harsha <pavit... at MIT.EDU> wrote:
> ... I have a color and a thickness attribute for each edge of the
> graph. I have extended my code from on the posts on thickness
> (http://forums.wolfram.com/mathgroup/archive/2008/Feb/msg00327.html).
> So, here is how I modified it. But the problem I have is that the
> attributes are getting matched with the edges in a different order.

I suppose that the getThickness function gets called whenever
GraphPlot gets around to setting up that edge.  There's no
particular reason to expect the edges to be set up in the order
they appear in your edge list.  Note that getThickness caches
its results, so you can just map that onto the edge list first.
The definition needs to be modified slightly though.  Thus,
the following works:

Clear[getThickness];
Clear[getColor];
Clear[e];

Freq[1] = 0.004; Freq[2] = 0.012; Freq[3] = 0.004;
Color[1] = Red; Color[2] = Blue; Color[3] = Green;
count = 1;
getThickness[{v1_, v2_}] := {getThickness[{v1, v2}] = Freq[count];
  count++;}
e = {LGA -> PHX, PHX -> LGA, LGA -> BOS};
getThickness /@ List @@@ e;
ColorCount = 1;
getColor[{v1_, v2_}] := {getColor[{v1, v2}] = Color[ColorCount];
  ColorCount++;}
g = GraphPlot[e, DirectedEdges -> True, VertexLabeling -> True,
      EdgeRenderingFunction -> ({getColor[#2],
      Thickness[getThickness[#2]], Arrowheads[{{.05, .8}}],
      Arrow[#1]} &),
  PlotRange -> {{0, 2}, {-0.08, 0.08}}]



  • Prev by Date: Re: Visualization of a list of 3D points coordinates with a perspective
  • Next by Date: Integral Questions
  • Previous by thread: How do I use EdgeRenderingFunction in GraphPlot with one command
  • Next by thread: Re: Mathematica Question