MathGroup Archive 2005

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

Search the Archive

Re: plotting weighted graphs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55373] Re: plotting weighted graphs
  • From: yehuda ben-shimol <bsyehuda at gmail.com>
  • Date: Sun, 20 Mar 2005 04:12:18 -0500 (EST)
  • References: <200503181035.FAA14751@smc.vnet.net>
  • Reply-to: yehuda ben-shimol <bsyehuda at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Mark,
I fully agree with David's remark but I will still try to help
First I recommend to use the Combinatorica package for that purpose.
Start with 
<<DiscreteMath`Combinatorica`
now assume that you have the following adjacency matrix
a = {{Infinity, 1, 2}, {3, Infinity, Infinity}, {4, 2, Infinity}}
which represents a directed and weighted graph
convert it to a graph and copy the edge weights to the edge labels as
the following
g = SetEdgeLabels[g = FromAdjacencyMatrix[a, EdgeWeight, Type -> Directed], 
      GetEdgeWeights[g]];
and now polt it with ShowGraph
ShowGraph[g,EdgeLabel->True]
yehuda
On Fri, 18 Mar 2005 05:35:01 -0500 (EST), Erik Itter
<erik.itter at t-online.de> wrote:
> Hi, I have a hopefully quite easy question:
>     how do you plot graphs with weighted edges?
> 
> I have the matrix specified by its adjadcency matrix using different numbers
> as weights, works so
> far. Now I would like to plot the matrix numbering the vertices from 1 to n
> and label the edges with
> their weights. Its 5.1 therefore I think I could use GraphPlot (which draws
> the graph with no
> labeling at all at the moment [but colors depending on weights]) if I knew
> the proper
> EdgeStyleFunction and VertexStyleFunction.
> 
> 
> 
> All suggestions welcome.
> 
>


  • Prev by Date: Re: filling in an array
  • Next by Date: Re: filling in an array
  • Previous by thread: plotting weighted graphs
  • Next by thread: Re: plotting weighted graphs