-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (56 loc) · 2.24 KB
/
main.py
File metadata and controls
64 lines (56 loc) · 2.24 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import DataReader
import Node
import Painter
import Autoclust
paint = True
save_fig = True
source = "3MC.csv"
if __name__ == '__main__':
Painter.save_fig = save_fig
if "txt" in source:
data = DataReader.read_tsv("data/" + source)
else:
data = DataReader.read_csv("data/" + source)
nodes = []
node_id = 0
for row in data:
nodes.append(Node.Node(node_id, row[0], row[1], row[2]))
node_id += 1
if paint:
filename = source[0:-4] + "_labels"
Painter.draw_points_by_label(nodes, cluster_strength=None, filename=filename)
autoclust = Autoclust.Autoclust(nodes)
print("Triangulacja")
nodes = autoclust.get_edges_from_triangulation()
autoclust.remove_nodes_without_edges()
if paint:
print("Rysowanie")
filename = source[0:-4] + "_triangulation"
Painter.draw_nodes_with_edges(nodes, autoclust.all_edges, cluster_strength=None, filename=filename)
print("Statystyki")
autoclust.calculate_statistics()
print("Dzielenie krawedzi")
autoclust.split_edges()
print("Ukrywanie krawedzi")
autoclust.hide_long_and_short_edges()
print("Pierwsza predykcja")
nodes = autoclust.predict_clusters()
if paint:
print("Rysowanie")
filename = source[0:-4] + "_first_pred"
Painter.draw_points_by_prediction_with_edges(nodes, autoclust.all_edges, autoclust.cluster_strength, filename)
print("Przywracanie krotkich krawedzi")
nodes = autoclust.restore_short_edges_and_predict()
if paint:
print("Rysowanie")
filename = source[0:-4] + "_restore_short"
Painter.draw_points_by_prediction_with_edges(nodes, autoclust.all_edges, autoclust.cluster_strength, filename)
print("Secong order inconsistency")
autoclust.detect_second_order_inconsistency()
nodes = autoclust.repredict_clusters()
if paint:
print(" Rysowanie ")
filename = source[0:-4] + "_second_order"
Painter.draw_points_by_prediction_with_edges(nodes, autoclust.all_edges, autoclust.cluster_strength, filename)
filename = source[0:-4] + "_final"
Painter.draw_points_by_prediction(nodes, autoclust.cluster_strength, filename)