Way of Storing Edges

Revision en1, by fofao_funk, 2016-10-11 15:43:07

Hi all.

I've came across this way of storing edges in many codes:

void addEdge(int u, int v) {
    head[edges] = v;
    prev[edges] = last[u];
    last[u] = edges++;
}

How does it work? Why is it used over the 'traditional' array of vectors?

I appreciate your help!

Tags storing edges, graph

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English fofao_funk 2016-10-11 15:43:07 316 Initial revision (published)