I have a directed graph with this Edgelist defined as follow:

g = Graph[{1 -> 2, 1 -> 3, 1 -> 4, 1 -> 6, 2 -> 6, 3 -> 8, 3 -> 11, 4 -> 8, 5 -> 2, 5 -> 6, 5 -> 8, 6 -> 8, 6 -> 10, 6 -> 11, 7 -> 2, 7 -> 6, 8 -> 9, 8 -> 11, 9 -> 6, 10 -> 2, 10 -> 9, 11 -> 3,  11 -> 4, 11 -> 9, 11 -> 10}, VertexLabels -> "Name"]


then I want to get the adjacency matrix of this graph by using following:

AdjacencyMatrix[g]//MatrixForm


The first row of that result is:

{0,1,1,1,1,0,0,0,0,0,0}

but it should be:

{0,1,1,1,0,1,0,0,0,0,0}

Can anyone help me to show this adjacency matrix in true form?

• Vertex names can be anything, not just numbers. When they are consecutive integers, you might assume that they are ordered as 1,2,3,..., but this is not generally true. Make no assumptions about the vertex ordering, instead check it (see VertexList) or use VertexIndex. – Szabolcs Aug 16 '15 at 18:38

VertexList[g]

g = Graph[Table[i,{i,1,11}],{1 -> 2, 1 -> 3, 1 -> 4, 1 -> 6, 2 -> 6, 3 -> 8, 3 -> 11, 4 -> 8, 5 -> 2, 5 -> 6, 5 -> 8, 6 -> 8, 6 -> 10, 6 -> 11, 7 -> 2, 7 -> 6, 8 -> 9, 8 -> 11, 9 -> 6, 10 -> 2, 10 -> 9, 11 -> 3,  11 -> 4, 11 -> 9, 11 -> 10}, VertexLabels -> "Name"]