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: [mg123985] Re: Is this a bug in the Adjacency Matrix function? Using 8.9.4.0
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 4 Jan 2012 05:01:04 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201201031029.FAA20259@smc.vnet.net>

testgraph =
 Graph[(DirectedEdge[#1[[1]], #1[[2]]] & ) /@
   {{1, 3}, {2, 3}, {3, 4}, {3, 5}, {4, 6},
    {4, 7}, {5, 7}, {6, 7}},
  VertexLabels -> "Name", ImagePadding -> 10]

The documentation for AdjacencyMatrix states that the vertices are
assumed to be in the order given by VertexList[g].

vertexList = VertexList[testgraph]

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

Consequently, you are using the wrong table headings.

adjMatrix = AdjacencyMatrix[testgraph];

TableForm[adjMatrix // Normal,
 TableHeadings -> {vertexList, vertexList}]

Alternatively, reorder the table to match your headings.

TableForm[Transpose[Transpose[
    Normal[adjMatrix][[vertexList]]][[vertexList]]],
 TableHeadings -> {Range[7], Range[7]}]


Bob Hanlon


On Tue, Jan 3, 2012 at 5:29 AM, Richard Palmer <rhpalmer at gmail.com> 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?



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