Commit 0274b222 authored by Lars Esselink's avatar Lars Esselink
Browse files

- fixed the reading input and used classes for disk, edges and pillars

parent 385be600
......@@ -16,9 +16,12 @@ C_i = Cost of the i'th disk
public class Algorithm {
private final String fileName = "D:\\Documenten\\Google Drive\\Computing science\\Year 2\\Semester 1\\Algorithms and data structures (NWI-IBC027)\\project 1\\testcases\\01-sample.in";;
// private final String fileName = "D:\\Documenten\\Google Drive\\Computing science\\Year 2\\Semester 1\\Algorithms and data structures (NWI-IBC027)\\project 1\\testcases\\01-sample.in";
private final String fileName = "/home/ldesselink/Documents/CS/AD/project1/rep/testcases/01-sample.in";
private final Vector<Vector<Integer>> input = new Vector<>();
private final Vector<Vector<Integer>> disks = new Vector<>();
private final Vector<Pillar> pillars = new Vector<>();
private final Vector<Disk> disks = new Vector<>();
private final Vector<Edge> edges = new Vector<>();
private int N;
private int M;
private int W;
......@@ -32,6 +35,19 @@ public class Algorithm {
}
public void makeEdges(){
for(Pillar pillar1 : pillars){
for(Pillar pillar2: pillars){
for(Disk disk: disks){
if(distancePoints(pillar1.getX(),pillar1.getY(),pillar2.getX(),pillar2.getY()) != 0){
}
}
}
}
}
public void initiateVector(){
readFromFile();
......@@ -43,13 +59,17 @@ public class Algorithm {
W = input.get(0).get(2);
System.out.println("N: " + N + " M: " + M + " W: " + W + "\n");
Vector<Integer> temp = new Vector<>();
Disk tempDisk = null;
for(int i = N + 1; i <= N + M; i++){
temp.add(input.get(i).get(0));
temp.add(input.get(i).get(1));
tempDisk = new Disk(input.get(i).get(0),input.get(i).get(1));
disks.add(tempDisk);
}
disks.add(temp);
Pillar tempPillar = null;
for(int i = 1; i < N + 1; i++){
tempPillar = new Pillar(input.get(i).get(0),input.get(i).get(1));
pillars.add(tempPillar);
}
}
......@@ -70,6 +90,13 @@ public class Algorithm {
}
public double distancePoints(
double x1,
double y1,
double x2,
double y2) {
return Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
}
public void addToVector(String line){
String[] split = line.split("\\s+");
......@@ -82,11 +109,17 @@ public class Algorithm {
}
public void printVector(Vector<Vector<Integer>> temp){
for (Vector<Integer> tempVector : temp) {
for (Integer integer : tempVector) {
System.out.println(integer);
}
// public void printVector(Vector<Vector<Integer>> temp){
// for (Vector<Integer> tempVector : temp) {
// for (Integer integer : tempVector) {
// System.out.println(integer);
// }
// }
// }
public void printVector(Vector<Pillar> temp){
for (Pillar tempPillars : temp) {
System.out.println(tempPillars.getX() + " " + tempPillars.getY());
}
}
......
public class Disk {
private final long Cost;
private final long Radius;
public Disk(long Radius, long Cost){
this.Radius = Radius;
this.Cost = Cost;
}
public long getCost(){
return Cost;
}
public long getRadius(){
return Radius;
}
}
public class Edge {
private final Pillar pillar1;
private final Pillar pillar2;
private final long cost;
public Edge(Pillar pillar1, Pillar pillar2, long cost){
this.pillar1 = pillar1;
this.pillar2 = pillar2;
this.cost = cost;
}
public Pillar getPillar1() {
return pillar1;
}
public Pillar getPillar2() {
return pillar2;
}
public long getCost() {
return cost;
}
}
public class Pillar {
private final int X;
private final int Y;
public Pillar(int X, int Y){
this.X = X;
this.Y = Y;
}
public int getY(){
return Y;
}
public int getX(){
return X;
}
}
11 3 13
1 9
4 2
4 6
8 7
11 4
15 4
15 10
19 4
19 5
19 10
26 1
2 1
3 100
4 10000
4 4 100
0 10
0 30
0 55
0 80
5 4
10 4
15 6
20 10
50 50 100000
31424 51397
41051 54581
42246 44994
89455 24213
27658 4868
37702 85791
20925 96069
13465 81361
93095 53784
61750 59279
80203 14831
26470 90410
61368 3245
8183 53166
3590 46640
90217 92237
96293 27102
49516 11674
11326 60253
70188 34351
65253 83028
1252 45723
45805 97376
11829 70651
75023 46979
58455 61768
73312 29887
59571 65147
61425 15625
86830 83563
74571 42341
46861 74507
82640 88439
28731 59868
25048 66820
77619 45745
64371 94515
4338 20639
13625 70920
12529 97000
4759 83299
33145 12761
45575 76826
12798 43266
22241 57666
45123 48423
83747 24568
55258 99166
45452 40058
6788 77606
6298 716175
5032 524493
3133 329301
189 4582
5744 679160
6713 829908
7602 861928
1442 181713
4873 479767
726 69935
5529 529008
1279 159057
4322 469395
5681 656640
8657 967282
7347 858478
6943 754948
8862 995074
1162 149667
3301 333165
7401 886379
2972 325020
2042 172892
8538 964956
3375 340025
4316 450018
2257 278210
9034 998575
4172 418890
3345 348244
7905 934388
5575 585445
6112 692683
682 116933
6511 703884
4905 483944
7719 891747
3624 345347
4075 380714
856 124136
6489 727704
573 105829
534 57902
7604 889549
2390 288191
3582 400058
2110 268936
461 45386
41 12906
1097 156370
50 50 1000000
752111 986053
242503 879413
409143 148936
137029 651771
131795 680525
922025 324999
101744 302979
180652 60746
541514 471743
515650 377231
573162 90280
322470 95670
437835 632631
302082 267392
247236 289331
629799 958331
562982 246871
16304 974637
17413 586088
632738 798929
675728 661957
255875 576432
894611 651228
66006 596291
806192 798754
636582 472348
904787 336917
214877 239255
200264 213963
568212 486353
839027 761363
143907 130401
104633 919327
817374 519608
561370 176517
561109 870957
598302 580000
550256 312920
864740 780853
560899 4096
435495 449970
394608 444567
186108 640421
917117 119754
411836 499291
851046 313527
362591 866748
697239 133861
655939 659588
273512 100391
70669 903400
70667 882808
70636 639323
15861 154034
70650 734693
37563 345137
70679 975319
70635 616926
32091 308209
70677 952437
70637 662627
21027 267379
31831 281350
70645 707511
47676 429742
13696 71066
70634 549269
25586 268869
63146 485336
70642 702118
70671 905297
70668 899066
70644 671397
48581 392320
70666 879162
70648 698120
70663 838519
3091 16610
38274 351646
10901 3157
39230 357224
70659 737343
21024 252277
70673 915015
70674 946689
43707 357435
70639 678770
65081 547750
7796 29505
61404 513811
27691 307094
70664 849833
41614 396516
70678 949940
52807 450648
70657 820913
70653 707275
33044 335733
70675 951917
18353 204462
50 40 2000
4746 1018
12151 1667
1761 815
9430 1068
12101 682
6509 1365
5026 1144
6158 1505
622 942
10274 921
5265 1516
671 690
0 999
3481 642
5960 1568
10325 439
7369 967
8069 381
10657 335
7808 754
9707 1037
1340 1008
12151 335
11792 572
11038 440
1179 707
8426 335
7797 1004
1943 448
10363 335
11403 592
3279 685
4700 984
7120 1194
2504 658
2806 674
5908 1373
1923 470
3811 973
4346 984
4110 967
12151 1001
8884 335
10983 338
2768 749
0 333
9040 643
5250 1377
2129 335
5437 1544
195 652098
333 833158
120 190584
146 77237
231 230527
300 194706
193 679802
106 37996
330 773484
247 799750
250 590335
183 493353
328 231033
326 536094
187 136974
162 543973
259 455365
128 942866
1 791799
64 532568
114 713703
299 910290
60 162612
89 262656
302 225285
297 893789
123 97785
218 394565
79 186035
153 591526
23 427763
50 744009
203 196671
137 88125
56 323861
62 317260
275 953890
321 576274
215 685397
135 335533
300 300 10000000
5351332 6285664
7986207 7529715
1345216 1626196
2261020 1773513
3375334 883691
9748719 9239342
6883753 9207727
6795584 5436953
5232012 8271086
4168528 1870252
5062539 2655497
5670075 9733757
7898214 5709961
6440802 2692538
6371239 9399545
5233865 9525203
9590601 761681
6031378 7684842
5390825 590447
6739746 3564232
4479020 1359500
6961060 3173451
4139462 4741200
8118913 7316087
2470891 9670367
1683139 7538611
1597825 4356056
1521127 3706634
3693054 4672541
1532825 8584108
5064793 871354
9261668 371771
4067215 8393200
9267899 6342392
5455349 460698
7410345 1124253
1779820 2619052
7362817 8814247
4285926 8769903
8824745 6324811
8267472 4207430
6515255 9306337
8419130 2399280
9766650 6748112
1689544 1661210
4555723 5795340
2210332 6822400
2356750 6286386
9151046 9726722
3132037 3877099
4567896 7212231
6870851 508974
3592971 4327117
177726 5855884
1702788 8560649
5409764 5437708
6056225 8971481
8384303 2535757
3826902 1385688
1216394 6122342
1171812 8230886
5874104 8210099
2696397 7368001
5900039 6909476
4535113 6948747
5975225 9536091
1906422 7428039
5968724 4681937
1528919 3230172
6485605 5197874
5331602 3560666
1977631 6343761
5193647 1651302
9582777 8682078
607952 6792894
4191498 7953234
8699390 3845822
1986811 845011
9465099 9947127
7542522 6042315
2409792 5002245
8520750 2535908
5589065 528850
4396025 2866689
784177 7994976
3304452 498865
4709192 5724220
4386562 6159338
6888633 6292267
9645452 9405074
9444045 3782548
1767257 43246
78205 6008503
1762232 5035828
7357060 3532342
5938771 3220129
9455043 6528603
4729477 169936
7099860 3194798
9595886 6786127
9257902 4216488
3327353 1907316
9176467 2847345
7338027 8895313
5791369 7651905
8185373 7523230
6276090 6579445
7037557 1355822
9571546 7744508
3355198 5994600
9717937 5818933
2702441 1430492
5007221 8306368
8143496 3933715
2617022 2469902
7159081 1107248
5479577 53411
3300953 7023668
4943995 871674
1004935 6959882
8011573 6148217
2202687 3428662
1748400 186540
4268981 2481141
7652464 8797100
1576063 289673
2162091 4415578
8507068 4841318
8387160 4269584
2103093 9327091
3543519 2449186
6555761 6080064
3238831 8748116
219582 363976
9741723 3721737
554866 4330988
3338845 1108168
8718617 7149835
998615 3166429
8800965 4451903
8909518 5960551
30613 8501283
9308789 4817032