Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //DFS algorithm
- int *visited
- int order;
- dfs(graph g){
- visited = malloc(sizeof(int)*nV(g));
- order = 1;
- dfsR(g, 0);
- }
- dfsR(graph g, vertex v){
- visited[v] = order++;
- vertex w;
- for(w=0; w<nV(g); w++){
- if(!hasEdge(g,v,w)){
- continue;
- }
- if(!visited[w]){
- dfsR(g, w);
- }
- }
- }
- //return 1 if path exists between 'a' and 'b', 0 if path doesn't exist
- int pathExists(graph g, vertex a, vertex b){
- }
Add Comment
Please, Sign In to add comment