-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTrainBfs.java
More file actions
39 lines (32 loc) · 1.31 KB
/
MainTrainBfs.java
File metadata and controls
39 lines (32 loc) · 1.31 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
package test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class MainTrainBfs {
public static void main(String[] args) {
State A= new State("A");
State B= new State("B");
State C= new State("C");
State D= new State("D");
State E= new State("E");
State F= new State("F");
State H= new State("H");
State I= new State("I");
State J= new State("J");
A.addToNieboresList(B).addToNieboresList(F);
B.addToNieboresList(J).addToNieboresList(C);
F.addToNieboresList(E).addToNieboresList(I);
J.addToNieboresList(A);
C.addToNieboresList(H);
I.addToNieboresList(J);
H.addToNieboresList(I).addToNieboresList(J);
D.addToNieboresList(C).addToNieboresList(H).addToNieboresList(E);
Builder buffergraph= new Graphbuilder();
buffergraph.addToGraph(A).addToGraph(C).addToGraph(B).addToGraph(D).addToGraph(E).addToGraph(F);//build the graph
buffergraph.addToGraph(J).addToGraph(I).addToGraph(H);//build the graph
SearchableGraph graph=new SearchableGraph(buffergraph,A);//new graph to solve
graph.printGraphWithVretxes();
Searcher Bfs=new Bfs(); // new solver (bfs algorithm)
Bfs.search(graph);// this function solve all the routes from initial vertex
}
}