Re: Directed Graph from Adjacency Matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg58805] Re: [mg58783] Directed Graph from Adjacency Matrix
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Tue, 19 Jul 2005 04:10:14 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200507180721.DAA23417@smc.vnet.net>
- Reply-to: murray at math.umass.edu
- Sender: owner-wri-mathgroup at wolfram.com
Needs["DiscreteMath`Combinatorica`"] a = {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}; FromAdjacencyMatrix[a, Type -> Directed] â??Graph:<6, 3, Directed>â?? ShowGraph[%] (* output shows a directed cycle on 3 vertices *) However: mat = ToAdjacencyMatrix[Cycle[3, Directed -> True]] {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}} g = FromAdjacencyMatrix[mat, Type -> Directed] â??Graph:<6, 3, Directed>â?? ShowGraph[g] (* the complete directed graph on 3 vertices with each edgedirected both ways *) In view of the preceding, you may want to use adjacency lists, rather than the adjacency matrix, for directed graphs. confused wrote: > 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. > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Directed Graph from Adjacency Matrix
- From: confused <gtg368j@mail.gatech.edu>
- Directed Graph from Adjacency Matrix