Message Boards Message Boards


Not getting required adjacency matrix

Posted 9 years ago
2 Replies
2 Total Likes

Hello everyone,

I am new user of Mathematicia and have been trying to get my hands on this amazing tool by analyzing random graphs and networks related to my research. However, this tool does not returns the correct adjacency matrix for the graph as mentioned below:

Graph[{1 <-> 7, 1 <-> 2, 1 <-> 6, 2 <-> 3, 2 <-> 5, 3 <-> 4, 4 <-> 5, 5 <-> 6}]

The correct adjacency matrix for the above graph should be Correct Adjacency Matrix

But Mathematicia tool returns the answer as enter image description here

This is the syntax I have used: enter image description here

Please help me to know where am I going wrong. Thank you.

2 Replies

Thank you sir. Thanks a lot. I have tried by arranging the vertex list and got the correct answer. :)

Posted 9 years ago

Did you look at the documentation for AdjacencyMatrix in the help system and click on the little triangle next to Details.

That is hiding: The vertices Subscript[v, i] are assumed to be in the order given by VertexList[g].

For your graph I get

In[8]:= VertexList[g]

Out[8]= {1, 7, 2, 6, 3, 5, 4}

I think that explains the result you are getting.

Helpful tip: Always click on Details, sometimes called Details and Options, but always click on that and read the contents.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract