Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: label graph vertices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74514] Re: label graph vertices
  • From: danl at wolfram.com
  • Date: Fri, 23 Mar 2007 19:15:56 -0500 (EST)
  • References: <ett7ks$id6$1@smc.vnet.net>

alexxx.magni at gmail.com wrote:
> greetings,
> after having used for some time a very powerful program (Graphviz) for
> displaying the graph structures I'm working on, I decided to give it a
> try under Mathematica, since I use M. for many other related tasks.
>
> I started from DiscreteMath`GraphPlot`, but from what I can see
> everything is done using an adjacency matrix composed of (0,1)'s,
> right?
> That is, my problem is that I need to LABEL the vertices with a name,
> instead of a position.
> >From http://documents.wolfram.com/mathematica/functions/AdvancedDocumentationGraphPlot
> I thought for a moment it was possible (e.g. see graph under
> "MaximalBipartiteMatching" with Tom,Rob,Adam etc), but I then realized
> it was demonstration-only, and no code is present to do it
>
> am I right, or there is a way?
>
> thanks for any help...
>
> Alessandro Magni

I received the following response from Yifan Hu, who is the developer
at WRI responsible for GraphPlot.

Daniel Lichtblau
Wolfram Research

-------------------

One way to do what you want is

GraphPlotLabeled[g_, opts___?OptionQ] := Module[
   {vtx, coord},
   Needs["DiscreteMath`GraphPlot`"];
   vtx = VertexList[g];
   coord = GraphCoordinates[g, opts];
   GraphPlot[g,
     VertexStyleFunction -> (Text[vtx[[#]], coord[[#]],
             Background -> Yellow] &)]];

GraphPlotLabeled[{"a" -> "b", "b" -> "c", "c" -> "d", "d" -> "a", "a" -
> "c"}]

post a sample of your graph would help to figure out how to help you
better.

-------------------



  • Prev by Date: Re: Integrate
  • Next by Date: simplifications
  • Previous by thread: Re: label graph vertices
  • Next by thread: Suggestion for direct commands ParametricPlot22 and ParametricPlot33