Click to See Complete Forum and Search --> : A graphs adjecency matrix? How do I work it out?


themoffster
January 24th, 2005, 01:41 PM
I have a graph setup and working correctly - all nodes/edges etc are working correctly.

I am now trying to implement Dijkstra's shortest path algorithm.
After searching on Google, every example and piece of source code uses an adjecency matrix to represent the graph.

Why is this and how does it correspond to the graph? Surely it would be easier to just refer to the graph as a series of nodes and edges rather than creating this matrix.

How do you workout the matrix for a graph you have?
It's got me rather confused!

_uj
January 24th, 2005, 02:11 PM
How do you workout the matrix for a graph you have?
It's got me rather confused!

An adjacency matrix is a two dimensional matrix storing the costs. Say this matrix is called A. The cost to travel between two nodes i and j is A[i,j]. If you go from j to i it's A[j,i].