|
@@ -10,40 +10,14 @@ fun solveFile(file : File) {
|
10
|
10
|
println(graph)
|
11
|
11
|
|
12
|
12
|
val solution = solveGraph("Start", "End", graph)
|
13
|
|
- println("Distance was ${solution.size} and route is $solution.")
|
14
|
|
- println(solution.map {
|
15
|
|
- val n = graph.nodes[it]!!
|
16
|
|
- n.info.point
|
17
|
|
- })
|
18
|
|
- println(solution.map {
|
19
|
|
- val n = graph.nodes[it]!!
|
20
|
|
- toVec(n.info.point).len()
|
21
|
|
- })
|
|
13
|
+ println("Distance was ${solution.size-1} hops and intermediate route is ${solution.subList(1,solution.size-1)}.")
|
22
|
14
|
|
23
|
|
- val nodeList = graph.nodes.toList()
|
24
|
|
- for (i in 1..solution.size-1) {
|
25
|
|
- val a = graph.nodes[solution[i-1]]!!
|
26
|
|
- val b = graph.nodes[solution[i]]!!
|
27
|
|
-
|
28
|
|
- val av = toVec(a.info.point)
|
29
|
|
- val bv = toVec(b.info.point)
|
30
|
|
-
|
31
|
|
- val cv = bv - av
|
32
|
|
-
|
33
|
|
- println("From ${a.info.name} to ${b.info.name}")
|
34
|
|
- for (j in 1 .. 1000) {
|
35
|
|
- val f = j * 0.001
|
36
|
|
- val dist = (av + cv*f).len()
|
37
|
|
- if (dist < EARTH_RADIUS) {
|
38
|
|
- println(dist)
|
39
|
|
- }
|
40
|
|
- }
|
41
|
|
- println("")
|
42
|
|
- }
|
|
15
|
+ verify(graph, solution)
|
43
|
16
|
}
|
44
|
17
|
|
|
18
|
+
|
45
|
19
|
fun main(args : Array<String>) {
|
46
|
|
- //solveFile(File("src/main/resources/satellites.txt"))
|
47
|
|
- //solveFile(File("src/main/resources/satellites2.txt"))
|
|
20
|
+ solveFile(File("src/main/resources/satellites.txt"))
|
|
21
|
+ solveFile(File("src/main/resources/satellites2.txt"))
|
48
|
22
|
solveFile(File("src/main/resources/satellites3.txt"))
|
49
|
23
|
}
|