tags:

views:

73

answers:

1

I have learned the basics of graph data structures. Now I want to implement all the structure/algorithms/operations that can be performed on graphs.

Please share some useful links wherein I can get started doing graph implementations in C.

+2  A: 

adjacency list and adjacency matrix are the two most classic alternatives for implementing graphs. I'm not sure if there are many examples of each online in C, but here is one for the adjacency matrix representation.

Alex Martelli
Thanks Alex.... Looks pretty good example... I will work it out..... but there is one article on adjacency list with incomplete implementation http://www.cs.bu.edu/teaching/c/graph/linked/........ But i am finding it difficult to get the start.... Can you help it out..... I have understood the structures,, but now if we want to insert a vertex or edge.. etc....
AGeek
@AGeek, in adj matrix: insert edge (between existing vertices I and J) → just set the `matrix[I][J]=1`; insert new vertex N+1 → allocate new N+1 by N+1 matrix and copy the old one over padding with the new row and col of 0s. adj list: in adj matrix: insert edge (between existing vertices I and J) → append J to the adj list of I; insert new vertex → append it to the list of existing vertices.
Alex Martelli