-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegular.java
More file actions
30 lines (24 loc) · 825 Bytes
/
Regular.java
File metadata and controls
30 lines (24 loc) · 825 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
package java.grafo;
public class Regular extends Grafo{
public Regular(){
}
public boolean analisaRegular(Grafo g){
boolean primeiraVez = true;
int qtdVizPrim = 0;
Lista no = g.prim;
if (no.prox_no == null) return true; //Se so tiver 1 no no grafo
do{ //Verifica para cada no
Vizinho aux = no.prox_viz;
int qtdViz = 0;
while (aux != null) { //Se vizinho não for null
if(primeiraVez) qtdVizPrim += 1;
else qtdViz += 1;
aux = aux.prox;
}
if(!primeiraVez) if (qtdViz != qtdVizPrim) return false;
if(primeiraVez) primeiraVez = false;
no = no.prox_no;
}while(no != null);
return true;
}
}