Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DFS(Graph G, int depth, int start, int end) {
- if ((depth == 0) && (start == end)) {
- path.push(start);
- System.out.println("" + path);
- return;
- }
- if (depth == 0)
- return;
- for (int i = 0; i < numVertex; i++) {
- if ((adj[start][i]) && (!visited.contains(i))) {
- path.push(start);
- visited.push(start);
- DFS(G,depth-1,i,end);
- visited.pop();
- path.pop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement