Skip to content

Instantly share code, notes, and snippets.

@ugandapinik
Last active July 16, 2021 01:41
Show Gist options
  • Save ugandapinik/45018e4bea98bde4b0f07db05d83ef86 to your computer and use it in GitHub Desktop.
Save ugandapinik/45018e4bea98bde4b0f07db05d83ef86 to your computer and use it in GitHub Desktop.
public static int[] visited = new int[8];
public void traverse(int[][] G, int u){
if (visited[u] == 0){
System.out.print(u + " ");
visited[u] = 1;
for (int v = 1; v <G.length; v++){
if (G[u][v] == 1 && visited[v] == 0){
traverse(G, v);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment