The Adjacency Matrix is a n by n matrix used to represent the connections between n vertices in a graph. In the adjacency matrix, rows and columns correspond to vertices, with each cell A[i][j]
being filled with 1 if vertices i
and j
are connected, and 0 otherwise. It can also be a weighted value if the graph includes edge weights.
A[i][j]
equals A[j][i]
.A[i][j]
represents the existence of an edge directed from vertex i to vertex jIt is often used to efficiently analyze graphs, determine connectivity, and perform various graph algorithms.
Toggle between the directed and undirected graph to see the difference.
Because no loop is allowed in the interactive area, the diagonal values in the matrix are all 0.
Edit the undirected graph so that it is equal to the adjacency matrix below:
[
[0,1,1,1,0],
[1,0,0,0,1],
[1,0,0,0,1],
[1,0,0,0,0],
[0,1,1,0,0]
]
Edit the directed graph so that it is equal to the adjacency matrix below:
[
[0,0,0,1,0],
[0,0,0,0,0],
[0,1,0,0,0],
[0,0,0,0,1],
[0,1,1,0,0]
]
Node Index:
Node ID:
0
,
1
,
2
,
3
,
4
[
0
,
1
,
1
,
0
,
0
]
[
1
,
0
,
0
,
0
,
0
]
[
1
,
0
,
0
,
0
,
0
]
[
0
,
0
,
0
,
0
,
0
]
[
0
,
0
,
0
,
0
,
0
]