metodo para saber si un grafo es conexo grafos

Technology

metodo para saber si un grafo es conexo grafos


public boolean conexo() {
Object[][] rsult = generaMatrizAdyacencia();
int x = 0;
if (rsult.length > 0) {
for (int i = 0; i < rsult.length - 1; i++) {
for (int j = 0; j < rsult.length - 1; j++) {
if (i != j) {
if ((Integer) rsult[i][j] == 0 && (Integer)
rsult[j][i] == 0) {
x += 1;
}} }
if (x == rsult.length - 1) {
return false;
}
x = 0;
}
return true;
}
return false;
}

Post a Comment

0 Comments