# Not getting required adjacency matrix

**URL:** <https://community.wolfram.com/t/not-getting-required-adjacency-matrix/3998>\
**Category:** Questions\
**Tags:** graphs-and-networks\
**Created:** [November 14, 2014, 11:01pm UTC](https://community.wolfram.com/t/not-getting-required-adjacency-matrix/3998 "2014-11-14T23:01:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdazharuddin254](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mdazharuddin254/32/10842_2.png) [@mdazharuddin254](https://community.wolfram.com/u/mdazharuddin254)\
**Post date:** [November 14, 2014, 11:01pm UTC](https://community.wolfram.com/t/not-getting-required-adjacency-matrix/3998/1 "2014-11-14T23:01:39Z")

</div>

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

 ![Actualadjacentmatrix.PNG](https://global.discourse-cdn.com/wolfram/original/3X/b/1/b16cf0b995ac9e821f6c475b5f5933ff23224433.png)

But Mathematicia tool returns the answer as

 ![Outputofmathematicia.PNG](https://global.discourse-cdn.com/wolfram/original/3X/b/2/b27eaae7759f6279e1849c15ae17f6284d9bf274.png)

This is the syntax I have used:

 ![Capture.PNG](https://global.discourse-cdn.com/wolfram/original/3X/7/8/782a7300ca439e25ae1b617f892133b749558199.png)

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

---

<div class="post-metadata">

**Author:** ![bsimpson141421356](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bsimpson141421356](https://community.wolfram.com/u/bsimpson141421356)\
**Post date:** [November 15, 2014, 4:35am UTC](https://community.wolfram.com/t/not-getting-required-adjacency-matrix/3998/2 "2014-11-15T04:35:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mdazharuddin254](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mdazharuddin254/32/10842_2.png) [@mdazharuddin254](https://community.wolfram.com/u/mdazharuddin254)\
**Post date:** [November 16, 2014, 12:17am UTC](https://community.wolfram.com/t/not-getting-required-adjacency-matrix/3998/3 "2014-11-16T00:17:22Z")

</div>

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