-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
48 lines (42 loc) · 1.76 KB
/
Main.java
File metadata and controls
48 lines (42 loc) · 1.76 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package java.grafo;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in;
in = new BufferedReader(new FileReader("src/lista.txt")); //LEMBRAR DE TROCAR PRA ARGS[0]
try {
while(true){
Grafo gr = new Grafo();
String str = in.readLine();
if(str == null) break;
String[] linha = str.split(" ");
for (int i = 0; i < linha.length; i++) {
gr.insere(Integer.parseInt(linha[i]));
}
while (!(str = in.readLine()).equals("FIM")){
linha = str.split(" ");
gr.insere(Integer.parseInt(linha[0]), Integer.parseInt(linha[1]));
}
Completo comp = new Completo();
boolean respComp = comp.analisaCompleto(gr);
Bipartido bip = new Bipartido(gr);
boolean respBip = bip.analisaBipartido(gr);
Regular reg = new Regular();
boolean respReg = reg.analisaRegular(gr);
if(!respBip & !respComp & !respReg) System.out.println("Simples");
else{
if(respBip) System.out.print(" java.grafo.Bipartido");
if(respComp) System.out.print(" java.grafo.Completo");
if(respReg) System.out.print(" java.grafo.Regular");
System.out.println();
}
}
in.close();
}catch (Exception e){
System.out.println("Excecao\n");
e.printStackTrace();
}
}
}