MathGroup Archive 2005

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

Search the Archive

Re: A very EZ Question! Make a Graph!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60283] Re: [mg60262] A very EZ Question! Make a Graph!
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 10 Sep 2005 06:46:35 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

Needs["DiscreteMath`Combinatorica`"];

e={{1,2},{2,3},{4,5},{1,4},{2,5}};

am=Table[0,{5},{5}];

ReleaseHold[HoldForm[
          am[[Sequence@@#]]=
            am[[Sequence@@Reverse[#]]]=1]&/@e];

ShowLabeledGraph[g=FromAdjacencyMatrix[am]];

Position[#,1]&/@ToAdjacencyMatrix[g]

{{{2}, {4}}, {{1}, {3}, {5}}, {{2}}, {{1}, {5}}, {{2}, {4}}}


Bob Hanlon

> 
> From: "mumat" <csarami at gmail.com>
To: mathgroup at smc.vnet.net
> Date: 2005/09/09 Fri AM 04:07:01 EDT
> Subject: [mg60283] [mg60262] A very EZ Question! Make a Graph!
> 
> Hi Everybody,
> 
> I need to make a graph given the vertices and edges.
> 
> let's say:
> 
> Vertex set: V=Range[5]={1,2,3,4,5}
> Edge Set:   E={{1,2},{2,3},{4,5},{1,4},{2,5}};
> 
> Also, Is there any funtion that Lists the vertices adjacent to a given
> vertex! I mean using the Combinatorica package in Mathematica!
> 
> 
> I know it might sound stupid, but I could find a solution to this in
> Mathematica Manual!!!
> 
> I appreciate your help.
> 
> regards,
> 
> chekad
> 
> 


  • Prev by Date: Timed Notebooks for Student Take-home examinations
  • Next by Date: Re: Why this function does not return a single value
  • Previous by thread: A very EZ Question! Make a Graph!
  • Next by thread: Re: A very EZ Question! Make a Graph!