Say I have the following adjacency matrix:
A B C D
A 0 9 0 5
B 9 0 0 0
C 0 0 0 2
D 5 0 2 0
How would this acutally be implemented? I realize I can use a 2D array to represent the weighted edges between vertices but I’m not sure how to represent the vertices.
int edges[4][4];
string vertices[4];
Is this the way to do it? The index in the vertices array corresponds to the row index in the edges array.
You can use a two dimensional
std::mapUsing this method allows for the matrix to grow and shrink when ever you want.