-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
67 lines (49 loc) · 1.22 KB
/
__init__.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sys
sys.path.append('components')
sys.path.append('algorithm')
sys.path.append('util')
sys.path.append('')
import random
from Element import *
from Vertex import *
from Set import *
from Parser import *
from Graph import *
from ParseSet import *
from ParseGraph import *
from TravellingSalesman import *
from KCenter import *
def main():
testTravellingSalesman()
def testKCenter():
vertices = []
for i in range(1, 1000):
vertex = Vertex()
vertex.pos.x = random.randint(-100, 100)
vertex.pos.y = random.randint(-100, 100)
vertices.append(vertex)
kSet = solveKCenter(vertices, 10)
graph = Graph(kSet) # For debugging
print graph.toString()
def testLoad():
graph = loadGraph("res/graph_one.algdata")
print graph.toString()
for v in graph.vertices:
print v.toString()
sets = loadSet("res/set_example.algdata")
for set in sets:
usets = set.getSetElements()
elements = set.getNonSetElements()
for s in usets:
print s
for e in elements:
print e
def testTravellingSalesman():
graph = loadGraph("res/graph_test.algdata")
tsp = solveTravellingSalesmanNearestAddition(graph)
for v in tsp:
print v.toString()
def printDebugGraph(graph):
print graph.toString()
if __name__ == "__main__":
main()