MathGroup Archive 2008

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

Search the Archive

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

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
> (
> 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:


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];
e = {LGA -> PHX, PHX -> LGA, LGA -> BOS};
getThickness /@ List @@@ e;
ColorCount = 1;
getColor[{v1_, v2_}] := {getColor[{v1, v2}] = Color[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