metodo mostrar los vertices sumideros grafos

Technology

metodo mostrar los vertices sumideros grafos


public LinkedList sumidero() {
LinkedList lista = new LinkedList();
if (vertices.size() > 1) {
for (int i = 0; i < vertices.size(); i++) {
Vertice v = vertices.get(i);
sumidero(v, lista);
}
return lista;
}
return null;
}
private void sumidero(Vertice v, LinkedList lista) {
int x = 0;
if (v.getAristas().size() > 0) {
for (int i = 0; i < v.getAristas().size(); i++) {
Arista a = v.getAristas().get(i);
if (a.getDestino().getAristas().size() == 0) {
if (!lista.contains(a.getDestino())) {
lista.add(a.getDestino());
}
} else {
for (int j = 0; j <
a.getDestino().getAristas().size(); j++) {
Arista ar =
a.getDestino().getAristas().get(j);
if (!
ar.getDestino().equals(a.getDestino())) {
x = ar.getDestino().getAristas().size()
+ 1;
j = x;
}
}
if (x == 0) {
if (!lista.contains(a.getDestino())) {
lista.add(a.getDestino());
}
}
}
}
} }

Post a Comment

0 Comments