Re: Mathematica Question
- To: mathgroup at smc.vnet.net
- Subject: [mg89248] Re: Mathematica Question
- From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
- Date: Sun, 1 Jun 2008 16:32:36 -0400 (EDT)
- References: <Pine.LNX.4.64L.0805311525260.15809@e51-075-5.mit.edu>
Please send these kinds of questions to MathGroup directly. That way you'll have a higher chance of getting a reply. I don't even have access to a machine with Mathematica installed at the moment. (Note: I forwarded your message to MathGroup) On Sat, May 31, 2008 at 10:36 PM, Pavithra Harsha <pavithra at mit.edu> wrote: > > Hi, > > I am Pavithra. I have a question in Mathematica and I saw your post to a > similar question I have and I thought I would directly email you. I found > your email add on > http://forums.wolfram.com/mathgroup/archive/2008/Feb/msg00318.html > > I have never used Mathematica before and I have to draw a graph and > graphplot seems a nice way to do it. I would greatly appreciate it if you > can tell me how to do this. If yes, please proceed below. > > Thanks, > Pavithra > > Let us say for this same example on the above web page, the attributes I > have for each edges are color and thickness. And I have parallel arcs > between two cities of different colors. The position command takes the > attribute of the first edge and not the corresponding ones. > > So, here are two ways I tried: > > thick = {0.012, 0.012, 0.012, 0.004, 0.004, 0.004, 0.004, 0.004, > 0.004}; > Color = {Red, Red, Red, Blue, Green, Green, Blue, Blue, Green}; > edges = {LGA -> PHX, PHX -> ORD, ORD -> LGA, PHX -> LGA, LGA -> BOS, > BOS -> PHX, ORD -> PHX, LGA -> ORD, PHX -> LGA}; > g = GraphPlot[edges, VertexLabeling -> True, > EdgeRenderingFunction -> ({Color[[First@ > First@Position[edges, Rule @@ #2]]], > Thickness[thick[[First@First@Position[edges, Rule @@ #2]]]], > Arrowheads[{{.07, .8}}], Arrow[#1]} &)] > > > I tried it the other way specified on the other solution provided to the > same problem on the forum > > Clear[getThickness]; > Clear[getColor]; > Clear[e]; > Array[Freq, 3]; > Freq[1] = 0.004; Freq[2] = 0.012; Freq[3] = 0.004; > Array[Color, 3]; > Color[1] = Red; Color[2] = Blue; Color[3] = Green; > count = 1; > getThickness[d_] := {getThickness[d] = Freq[count]; count++;} > ColorCount = 1; > getColor[d_] := {getColor[d] = Color[ColorCount]; ColorCount++;} > e = {LGA -> PHX, PHX -> LGA, LGA -> BOS}; > g = GraphPlot[e, DirectedEdges -> True, VertexLabeling -> True, > EdgeRenderingFunction -> ({getColor[#1], > Thickness[getThickness[#1]], Arrowheads[{{.05, .8}}], > Arrow[#1]} &)] > > > In this way, it does not pick the edges in the same order as I have > specified. So, the color and thickness attributes are going to different > edges than the edges I have specified > > > > > > ````````````````````````````````````````````````````````````````````````````` > Operations Research Center, MIT > 77 Massachusetts Avenue, Bldg. E40-130 > Cambridge MA 02139 > Phone No: 617-253-7412 > >