[prev] 3 [next]

Graph Traversal (cont)

Previous expression of algorithms used
  • g->nV to get #vertices,   g->nE to get #edges
  • g->edges[v][w] to check for existence of edge (v,w)
The above makes assumption about graph representation (adj.matrix)

To make things more representation-independent, use

  • nV(g) to get #vertices,   nE(g) to get #edges
  • hasEdge(g,v,w) to check for existence of edge (v,w)