Guest User

Untitled

a guest
Oct 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //DFS algorithm
  2. int *visited
  3. int order;
  4.  
  5. dfs(graph g){
  6. visited = malloc(sizeof(int)*nV(g));
  7. order = 1;
  8. dfsR(g, 0);
  9. }
  10.  
  11. dfsR(graph g, vertex v){
  12. visited[v] = order++;
  13. vertex w;
  14. for(w=0; w<nV(g); w++){
  15. if(!hasEdge(g,v,w)){
  16. continue;
  17. }
  18. if(!visited[w]){
  19. dfsR(g, w);
  20. }
  21. }
  22. }
  23.  
  24. //return 1 if path exists between 'a' and 'b', 0 if path doesn't exist
  25. int pathExists(graph g, vertex a, vertex b){
  26.  
  27. }
Add Comment
Please, Sign In to add comment