Implementation of BFS, UCS and DFS
-
The vertices and their parents (called as parent sets) are read from
data0.txt
-
All of the vertices are read and made into objects like these:
After the generation of all the vertices from the data file, all permutations of these vertices are created
Each permutation's cost is calculated using this functionality:
Consider the following short data file:
which represents the following example:
Consider the ordering (5, 3, 1, 4, 2). With respect to vertex 1, the parent set {4} is not consistent with the ordering. The parent sets {}, {3}, and {5} are consistent with the ordering The ordering (5, 3, 1, 4, 2) has a total cost of 96.093 + 121.576 + 41.775 + 36.188 + 169.802 = 465.435. whereas the ordering (1, 2, 3, 4, 5) has a total cost of 153.466 + 141.022 + 107.516 + 51.680 + 36.508 = 490.192
A graph is made for all permutation objects
Now BFS, DFS, and UCS are applied to find the minimum cost permutation