Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7554 > unrolled thread

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

Started byRichard Palmer <rhpalmer@gmail.com>
First post2012-01-03 10:32 +0000
Last post2012-01-04 10:06 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Is this a bug in the Adjacency Matrix function? Using 8.9.4.0 Richard Palmer <rhpalmer@gmail.com> - 2012-01-03 10:32 +0000
    Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0 Szabolcs <szhorvat@gmail.com> - 2012-01-04 10:06 +0000

#7554 — Is this a bug in the Adjacency Matrix function? Using 8.9.4.0

FromRichard Palmer <rhpalmer@gmail.com>
Date2012-01-03 10:32 +0000
SubjectIs this a bug in the Adjacency Matrix function? Using 8.9.4.0
Message-ID<jdulgc$jr3$1@smc.vnet.net>
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?

[toc] | [next] | [standalone]


#7564

FromSzabolcs <szhorvat@gmail.com>
Date2012-01-04 10:06 +0000
Message-ID<je18bv$3d8$1@smc.vnet.net>
In reply to#7554
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]}]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web