How to draw graph with named vertices by adjacency matrix?

I have the adjacency matrix of graph and I want visualize this graph. I tried:

AdjacencyGraph[{v1,v2,v3,v4,v5,v6,v7,v8,v9,v10},
{{0,0,0,1,0,1,1,1,0,0},
{0,0,0,0,0,1,1,1,1,1},
{0,0,0,0,0,0,0,1,1,0},
{1,0,0,0,0,0,0,1,0,0},
{0,0,0,0,0,1,0,1,0,0},
{1,1,0,0,1,0,1,0,1,1},
{1,1,0,0,0,1,0,0,0,1},
{1,1,1,1,1,0,0,0,0,1},
{0,1,1,0,0,1,0,0,0,0},
{0,1,0,0,0,1,1,1,0,0}}]

and

AdjacencyGraph[
{{0,0,0,1,0,1,1,1,0,0},
{0,0,0,0,0,1,1,1,1,1},
{0,0,0,0,0,0,0,1,1,0},
{1,0,0,0,0,0,0,1,0,0},
{0,0,0,0,0,1,0,1,0,0},
{1,1,0,0,1,0,1,0,1,1},
{1,1,0,0,0,1,0,0,0,1},
{1,1,1,1,1,0,0,0,0,1},
{0,1,1,0,0,1,0,0,0,0},
{0,1,0,0,0,1,1,1,0,0}}]

Output is:

How to add names of vertices to graph?

=================

=================

3 Answers
3

=================

VertexLabelsdoes the job.

AdjacencyGraph[{
{0, 0, 0, 1, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 1, 0, 0},
{1, 1, 0, 0, 1, 0, 1, 0, 1, 1},
{1, 1, 0, 0, 0, 1, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 0, 0, 0, 0, 1},
{0, 1, 1, 0, 0, 1, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 1, 1, 1, 0, 0}},
VertexLabels -> Table[i -> Subscript[v, i], {i, 10}]]

AdjacencyGraph[
{Labeled[v1, “1”],
Labeled[v2, “2”],
Labeled[v3, “3”],
Labeled[v4, “4”],
Labeled[v5, “5”],
Labeled[v6, “6”],
Labeled[v7, “7”],
Labeled[v8, “8”],
Labeled[v9, “9”],
Labeled[v10, “10”]},
{{0,0,0,1,0,1,1,1,0,0},
{0,0,0,0,0,1,1,1,1,1},
{0,0,0,0,0,0,0,1,1,0},
{1,0,0,0,0,0,0,1,0,0},
{0,0,0,0,0,1,0,1,0,0},
{1,1,0,0,1,0,1,0,1,1},
{1,1,0,0,0,1,0,0,0,1},
{1,1,1,1,1,0,0,0,0,1},
{0,1,1,0,0,1,0,0,0,0},
{0,1,0,0,0,1,1,1,0,0}}]

Similarily to the above:

Code:

g = {{0, 0, 0, 1, 0, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 1, 1,
1}, {0, 0, 0, 0, 0, 0, 0, 1, 1, 0}, {1, 0, 0, 0, 0, 0, 0, 1, 0,
0}, {0, 0, 0, 0, 0, 1, 0, 1, 0, 0}, {1, 1, 0, 0, 1, 0, 1, 0, 1,
1}, {1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 0, 0, 0, 0,
1}, {0, 1, 1, 0, 0, 1, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1, 1, 1, 0,
0}};

AdjacencyGraph[g, VertexLabels -> “Name”]

Output: