Meine Loesung kann mir jemand sagen ob es stimmt ?
public static boolean allReachable(boolean[][] ug, int node){
return countNeighbours(ug, node, 0) == (ug.length - 1);
}
public static int countNeighbours(boolean[][] ug, int node, int neighbour){
int result = 0;
if(neighbour == ug.length){
return result;
}
if(ug[node][neighbour]){
result += 1 + countNeighbours(ug, node, neighbour + 1);
}else{
result += countNeighbours(ug, node, neighbour + 1);
}
return result;
}