-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDFS1.java
More file actions
37 lines (27 loc) · 718 Bytes
/
Copy pathDFS1.java
File metadata and controls
37 lines (27 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.LinkedList;
public class DFS1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int V=4;
LinkedList<Integer> adj[];
adj=new LinkedList[V];
for(int i=0;i<V;i++)
{
adj[i]=new LinkedList();
}
addEdge(adj, 0, 1);
addEdge(adj, 0, 4);
addEdge(adj, 1, 2);
addEdge(adj, 1, 3);
addEdge(adj, 1, 4);
addEdge(adj, 2, 3);
addEdge(adj, 3, 4);
printAdjacencymatrix(adj);
}
private static void printAdjacencymatrix(LinkedList<Integer>[] adj) {
// TODO Auto-generated method stub
}
private static void addEdge(LinkedList<Integer>[] adj, int i, int j) {
// TODO Auto-generated method stub
}
}