Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123994] Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0
  • From: Szabolcs <szhorvat at gmail.com>
  • Date: Wed, 4 Jan 2012 05:04:11 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jdulgc$jr3$1@smc.vnet.net>
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

On Tuesday, 3 January 2012 11:32:44 UTC+1, Richard Palmer  wrote:
> testgraph=Graph[#[[1]]\[DirectedEdge]#[[2]]&/@{{1,3},{2,3},{3,4},{3,5},{4,6},{4,7},{5,7},{6,7}},
> VertexLabels->"Name",
> ImagePadding->10]
> 
> 
> MatrixForm[AdjacencyMatrix[testgraph],
>  TableHeadings -> {Range[7], Range[7]}]
> 
> 
> The Adjacency Matrix appears to be incorrect, e.g.  1 is not adjacent to 2.
>  What am I missing?

Writing an adjacency matrix assumes an ordering of vertices.  In Mathematica this is not a simple lexicographic ordering, but the ordering is the same as that returned by VertexList.

The correct code to show the adjacency matrix is

MatrixForm[AdjacencyMatrix[testgraph], 
 TableHeadings -> {VertexList[testgraph], VertexList[testgraph]}]



  • Prev by Date: Frameticks and ListLogLinearPlot
  • Next by Date: Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0
  • Previous by thread: Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0
  • Next by thread: how turn off camera after using CurrentImage?