Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Re: Directed Graph from Adjacency Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58863] Re: [mg58803] Re: Directed Graph from Adjacency Matrix
  • From: Ian Roberts <mathgroup at quantica.com.au>
  • Date: Thu, 21 Jul 2005 03:08:11 -0400 (EDT)
  • References: <dbflj5$n0m$1@smc.vnet.net> <200507190810.EAA11538@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I think that  FromAdjacencyMatrix[{{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}] 
should produce a Graph object with 3 correctly ordered pairs of vertices 
in it. It only contains the first 2. Adding Type->Directed should only 
order the pairs if needed and add  the arrows via Rule[EdgeDirection, 
True]. Interestingly, FromAdjacencyMatrix[{{0, 1, 0}, {0, 0, 1}, {0, 0, 
1}}] does produce the corresponding pairs of vertices.
Note that the inbuilt function works OK ie GraphPlot[{{0, 1, 0}, {0, 0, 
1}, {1, 0, 0}}] or GraphPlot[{{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}, 
EdgeStyleFunction -> Automatic] if you want the arrows.
Ian

Carl K. Woll wrote:

>"confused" <gtg368j at mail.gatech.edu> wrote in message 
>news:dbflj5$n0m$1 at smc.vnet.net...
>  
>
>>I am new to Mathematica.  Here is my question.  How would I get a
>>directed graph from an adjacency matrix?  For instance, the 3x3 matrix
>>{{0,1,0},{0,0,1},{1,0,0}} defines a directed 3-cycle, but when I try to
>>turn it into a graph using FromAdjacencyMatrix, Mathematica returns a
>>graph with only two edges.
>>
>>Thank you.
>>
>>    
>>
>
>Use the option Type->Directed:
>
>ShowGraph[FromAdjacencyMatrix[{{0,1,0},{0,0,1},{1,0,0}},Type->Directed]]
>
>produces a directed 3-cycle.
>
>Carl Woll
>Wolfram Research 
>
>
>
>
>
>  
>


  • Prev by Date: Re: How to create a new Form
  • Next by Date: Re: Getting crude approximation to a function
  • Previous by thread: Re: Directed Graph from Adjacency Matrix
  • Next by thread: Extract Coefficients of Fourier Series