-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfds++.cpp
More file actions
739 lines (668 loc) · 25.4 KB
/
fds++.cpp
File metadata and controls
739 lines (668 loc) · 25.4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
// fds.cpp
// 574
// Force Directed Scheduler
//
// Created by Kristopher Rockowitz on 11/30/19.
// Copyright © 2019 r0. All rights reserved.
//
// // *** Idea about selecting nodes where the predecessor force is guaranteed to be 0 ***
// // check if the parent size is 0 or if all parents are scheduled, then schedule a node
// bool scheduled = true;
// for(unsigned int p = 0; p < i->parent.size(); p++){
// if(!(i->parent.at(p)->scheduled)){
// scheduled = false;
// }
// }
// if(i->parent.size() == 0 || scheduled){
// // then do things
// }
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <limits>
using namespace std;
// inputs, outputs, registers, wires are of this type
class Variable {
public:
string name; // a, b, c, etc.
string type; // s for signed, u for unsigned
int bits; // bits 1, 2, 8, 16, 32, 64
// constructor
Variable(){
this->name = "";
this->type = "";
this->bits = 0;
}
Variable(string name, string type, int bits){
this->name = name;
this->type = type;
this->bits = bits;
}
};
// class that holds processed operations
// TODO: modify to incorporate 'if' statements
class Operation {
public:
Variable result; // the leftmost variable aka result of the op in most cases
string equals; // the equals operator
Variable var1; // the first variable after the equals sign
Variable var2; // the second variable after the equals sign
Variable var3; // the third variable after the equals sign
string op1; // the first operator
string op2; // the second operator
string name; // name of the operation
string type; // type (s for signed, u for unsigned)
int bits; // bits 1, 2, 8, 16, 32, 64
Operation(){
this->result = Variable();
this->equals = "";
this->var1 = Variable();
this->var2 = Variable();
this->var3 = Variable();
this->op1 = "";
this->op2 = "";
this->name = "";
this->type = "";
this->bits = 0;
}
};
class Node{
public:
Operation operation; // add/sub, mult, logic, div/mod
vector<string> inputs; // max 2 inputs, pretty sure it has to be this way
vector<Node*> parent;
vector<Node*> children;
string output; // max 1 output
int asap; // this is the first element of timeframe for FDS
int alap; // this is the second element of timeframe for FDS
int mobility; // alap - asap. also fyi, width = mobility + 1
bool asapScheduled;
bool alapScheduled;
bool scheduled; // default false, helps to shrink each iteration of FDS
int selfForce; // SUM(DG(i) * deltaX(i)) where DG(i) is time probability and
int fds;
int num;
Node(){
this->children = {};
this->inputs = {};
this->parent = {};
this->operation = Operation();
this->output = "";
this->alap = 0;
this->asap = 0;
this->mobility = 0;
this->scheduled = false;
this->asapScheduled = false;
this->alapScheduled = false;
this->selfForce = 0;
this->fds = 0;
this->num = 0;
}
};
class Graph{ // maybe, I don't really know how graphs work
public:
vector<Node> vertices;
Graph(){
}
};
// Self force function takes in a node, a time, and all the DGs. Iterates throught the timeframes and calculates all the negative probability components.
// Then with the time given, calcs the positive probability component and returns the self force.
// This works off the reduced equation: Self Force = DG(time) - Sum[DG(n) * prob(n)] where n is the interval of asap to alap.
float SelfForce(Node node, int time, vector<float> dg_mult, vector<float> dg_addsub, vector<float> dg_divmod, vector<float> dg_logic){
// loop through all time frames for a given node and get the negative part of self force. this represents the probability for all times in timeframe
float selfForce = 0.0;
// if the time given is outside of the asap to alap interval, the force is necessarily 0
if(time < node.asap || time > node.alap){
selfForce = 0.0;
}
else{
for(unsigned int n = node.asap; n <= node.alap; n++){
// calc 1/width for ease of use
float prob = 1/((float)node.alap - (float)node.asap + 1);
// operation type matters and so filter by operation type
if(node.operation.name == "MULT"){
// self force = DG(j) * deltaX(j) for alap - asap number of terms
selfForce -= dg_mult.at(n-1) * prob;
}
else if(node.operation.name == "DIV" || node.operation.name == "MOD"){
// self force = DG(j) * deltaX(j) for alap - asap number of terms
selfForce -= dg_divmod.at(n-1) * prob;
}
else if(node.operation.name == "ADD" || node.operation.name == "SUB"){
// self force = DG(j) * deltaX(j) for alap - asap number of terms
selfForce -= dg_addsub.at(n-1) * prob;
}
else if(node.operation.name == "COMP" || node.operation.name == "MUX" || node.operation.name == "SHR" || node.operation.name == "SHL"){
// self force = DG(j) * deltaX(j) for alap - asap number of terms
selfForce -= dg_logic.at(n-1) * prob;
}
}// end negative self force part
// add the positive component to self force. this represents the probability is 1 at the time given
if(node.operation.name == "MULT"){
selfForce += dg_mult.at(time-1);
}
else if(node.operation.name == "DIV" || node.operation.name == "MOD"){
selfForce += dg_divmod.at(time-1);
}
else if(node.operation.name == "ADD" || node.operation.name == "SUB"){
selfForce += dg_addsub.at(time-1);
}
else if(node.operation.name == "COMP" || node.operation.name == "MUX" || node.operation.name == "SHR" || node.operation.name == "SHL"){
selfForce += dg_logic.at(time-1);
}
}
return selfForce;
}
// calculates the predecessor forces for the given node
void PredecessorForce(Node s, int time, int size, vector<float> dg_mult, vector<float> dg_addsub, vector<float> dg_divmod, vector<float> dg_logic) {
// s is the node, time is the current scheduling time, size is the number of total nodes
// Initially mark all verices as not visited
vector<bool> visited(size, false);
// Create a stack for DFS
stack<Node> stack;
// Push the current source node.
stack.push(s);
// level used for time calculation
int level = 0;
//intialize predecessor force
float predecessorForce = 0.0;
int x = 0;
while (!stack.empty())
{
// Pop a vertex from stack and print it
s = stack.top();
stack.pop();
if (!visited[s.num]){
cout << s.num << " ";
visited[s.num] = true;
// if it's not the first node, evaluate whether pred force exists
if(x > 0){
float sf = 0.0;
// if the pred node has an alap that is greater than adj_time, calc self force at adj_time
int adj_time = time - level + 1;
if(s.alap >= adj_time){
sf = SelfForce(s, adj_time - 1, dg_mult, dg_addsub, dg_divmod, dg_logic);
}
else{
sf = 0.0;
}
predecessorForce += sf;
}
}
x++;
// increment the level every time the number of parents > 0
if(s.parent.size() > 0){
level++;
}
for (unsigned int i = 0; i < s.parent.size(); i++){
// check if the parent num is in the visisted array
if (!visited[s.parent.at(i)->num]){
stack.push(*s.parent.at(i));
}
}
}
cout << "level: " << level << endl;
}
// calculates the predecessor forces for the given node
tuple<float, int> TotalForce(Node s_in, int size, vector<float> dg_mult, vector<float> dg_addsub, vector<float> dg_divmod, vector<float> dg_logic) {
// s is the node, time is the current scheduling time, size is the number of total nodes
// TODO: add functionality so that when pred/succ forces are calculated, they set all the timeframes of connected nodes
Node s = s_in;
tuple<float, int> out;
float lowestForce = numeric_limits<float>::max(); // create super high float so any min is lower
for(unsigned int n = s.asap; n <= s.alap; n++){
// create a changes Vector
vector<Node> changes;
int time = n;
// calc self Force
float selfForce = SelfForce(s, time, dg_mult, dg_addsub, dg_divmod, dg_logic);
cout << "Self: " << selfForce;
// Initially mark all verices as not visited
vector<bool> visited(size, false);
// Create a stack for DFS
stack<Node> stack;
// Push the current source node.
stack.push(s);
// level used for time calculation
int level = 0;
//intialize predecessor force
float predecessorForce = 0.0;
int x = 0;
while (!stack.empty())
{
// Pop a vertex from stack and print it
s = stack.top();
stack.pop();
if (!visited[s.num]){
// cout << s.num << " ";
visited[s.num] = true;
// if it's not the first node, evaluate whether pred force exists
if(x > 0){
float sf = 0.0;
// if the pred node has an alap that is greater than adj_time, calc self force at adj_time
int adj_time = time - level + 1;
if(s.alap >= adj_time){
sf = SelfForce(s, adj_time - 1, dg_mult, dg_addsub, dg_divmod, dg_logic);
}
else{
sf = 0.0;
}
predecessorForce += sf;
}
}
x++;
// increment the level every time the number of parents > 0
if(s.parent.size() > 0){
level++;
}
for (unsigned int i = 0; i < s.parent.size(); i++){
// check if the parent num is in the visisted array
if (!visited[s.parent.at(i)->num]){
stack.push(*s.parent.at(i));
}
}
}
cout << " Pred: " << predecessorForce;
// Initially mark all verices as not visited
vector<bool> visited2(size, false);
// Push the current source node.
stack.push(s);
// level used for time calculation
level = 0;
//intialize successor force
float successorForce = 0.0;
x = 0;
while (!stack.empty())
{
// Pop a vertex from stack and print it
s = stack.top();
stack.pop();
if (!visited[s.num]){
// cout << s.num << " ";
visited[s.num] = true;
// if it's not the first node, evaluate whether pred force exists
if(x > 0){
float sf = 0.0;
// if the pred node has an alap that is greater than adj_time, calc self force at adj_time
int adj_time = time + level - 1;
if(s.asap <= adj_time){
sf = SelfForce(s, adj_time + 1, dg_mult, dg_addsub, dg_divmod, dg_logic);
}
else{
sf = 0.0;
}
successorForce += sf;
}
}
x++;
// increment the level every time the number of parents > 0
if(s.children.size() > 0){
level++;
}
for (unsigned int i = 0; i < s.children.size(); i++){
// check if the parent num is in the visisted array
if (!visited[s.children.at(i)->num]){
stack.push(*s.children.at(i));
}
}
}
cout << " Succ: " << successorForce;
float totalForce = selfForce + predecessorForce + successorForce;
cout << " Total: " << totalForce << endl;
if (totalForce * 1000 < lowestForce * 1000){
lowestForce = totalForce;
out = make_tuple(totalForce, n);
}
s = s_in;
}// end for
return out;
}
// changes times for nodes
//void ChangeTimes(Node &s, int time, int size, vector<float> dg_mult, vector<float> dg_addsub, vector<float> dg_divmod, vector<float> dg_logic) {
// // s is the node, time is the current scheduling time, size is the number of total nodes
//
// // change node to scheduled
// s.scheduled = true;
// s.alap = time;
// s.asap = time;
//
//
//
// // TODO: add functionality so that when pred/succ forces are calculated, they set all the timeframes of connected nodes
//
//
// // Initially mark all verices as not visited
// vector<bool> visited(size, false);
//
// // Create a stack for DFS
// stack<Node> stack;
//
// // Push the current source node.
// stack.push(s);
// // level used for time calculation
// int level = 0;
//
// int x = 0;
// while (!stack.empty())
// {
// // Pop a vertex from stack and print it
// s = stack.top();
// stack.pop();
//
// if (!visited[s.num]){
//// cout << s.num << " ";
// visited[s.num] = true;
// // if it's not the first node, evaluate whether pred force exists
// if(x > 0){
// if(s.alap >= time){
// s.alap = time - 1;
// }
// }
// }
// x++;
//
// // increment the level every time the number of parents > 0
// if(s.parent.size() > 0){
// level++;
// }
//
// for (unsigned int i = 0; i < s.parent.size(); i++){
// // check if the parent num is in the visisted array
// if (!visited[s.parent.at(i)->num]){
// stack.push(*s.parent.at(i));
// }
// }
// }
//// cout << "level: " << level << endl;
//
// // Initially mark all verices as not visited
// vector<bool> visited2(size, false);
//
// // Push the current source node.
// stack.push(s);
// // level used for time calculation
// level = 0;
//
// x = 0;
// while (!stack.empty())
// {
// // Pop a vertex from stack and print it
// s = stack.top();
// stack.pop();
//
// if (!visited[s.num]){
//// cout << s.num << " ";
// visited[s.num] = true;
// // if it's not the first node, evaluate whether pred force exists
// if(x > 0){
// if(s.asap <= time){
// s.asap = time + 1;
// }
// }
// }
// x++;
//
// // increment the level every time the number of parents > 0
// if(s.children.size() > 0){
// level++;
// }
//
// for (unsigned int i = 0; i < s.children.size(); i++){
// // check if the parent num is in the visisted array
// if (!visited[s.children.at(i)->num]){
// stack.push(*s.children.at(i));
// }
// }
// }
//
//}
//// calculates the successor forces for the given node
//void SuccessorForce(Node s, int time, int size, vector<float> dg_mult, vector<float> dg_addsub, vector<float> dg_divmod, vector<float> dg_logic) {
// // s is the node, time is the current scheduling time, size is the number of total nodes
//
// // Initially mark all verices as not visited
// vector<bool> visited(size, false);
//
// // Create a stack for DFS
// stack<Node> stack;
//
// // Push the current source node.
// stack.push(s);
// // level used for time calculation
// int level = 0;
//
// //intialize successor force
// float successorForce = 0.0;
// int x = 0;
// while (!stack.empty())
// {
// // Pop a vertex from stack and print it
// s = stack.top();
// stack.pop();
//
// if (!visited[s.num]){
// cout << s.num << " ";
// visited[s.num] = true;
// // if it's not the first node, evaluate whether pred force exists
// if(x > 0){
// float sf = 0.0;
// // if the pred node has an alap that is greater than adj_time, calc self force at adj_time
// int adj_time = time + level - 1;
// if(s.asap <= adj_time){
// sf = SelfForce(s, adj_time + 1, dg_mult, dg_addsub, dg_divmod, dg_logic);
// }
// else{
// sf = 0.0;
// }
// successorForce += sf;
// }
// }
// x++;
//
// // increment the level every time the number of parents > 0
// if(s.children.size() > 0){
// level++;
// }
//
// for (unsigned int i = 0; i < s.children.size(); i++){
// // check if the parent num is in the visisted array
// if (!visited[s.children.at(i)->num]){
// stack.push(*s.children.at(i));
// }
// }
// }
// cout << "level: " << level << endl;
//}
void DG(Graph g, vector<float>&dg_mult, vector<float>&dg_addsub, vector<float>&dg_divmod, vector<float>&dg_logic){
// populate the DG for each component
vector<Node>::iterator i;
// loop over all vertices / nodes, same thing
for(i = g.vertices.begin(); i != g.vertices.end(); i++){
float mobility = i->alap - i->asap;
// examine timeframe [asap, alap] and calc probability
// find the operation type so you know which vector to add to
if(i->operation.name == "MULT"){
// loop over the time intervals this operation covers
// start at asap, end at alap
for(unsigned int j = i->asap; j <= i->alap; j++){
// accumulate the probability for this component on the total
// type probability for this specific time
dg_mult[j-1] += 1 / (mobility + 1);
}
}
if(i->operation.name == "DIV" || i->operation.name == "MOD"){
// loop over the time intervals this operation covers
// start at asap, end at alap
for(unsigned int j = i->asap; j <= i->alap; j++){
// accumulate the probability for this component on the total
// type probability for this specific time
dg_divmod[j-1] += 1 / (mobility + 1);
}
}
if(i->operation.name == "ADD" || i->operation.name == "SUB"){
// loop over the time intervals this operation covers
// start at asap, end at alap
for(unsigned int j = i->asap; j <= i->alap; j++){
// accumulate the probability for this component on the total
// type probability for this specific time
dg_addsub[j-1] += 1 / (mobility + 1);
}
}
if(i->operation.name == "COMP" || i->operation.name == "MUX" || i->operation.name == "SHR" || i->operation.name == "SHL"){
// loop over the time intervals this operation covers
// start at asap, end at alap
for(unsigned int j = i->asap; j <= i->alap; j++){
// accumulate the probability for this component on the total
// type probability for this specific time
dg_logic[j-1] += 1 / (mobility + 1);
}
}
} // end DG for
}
void printVector(vector<float> vec){
for(int x = 0; x < vec.size(); x++){
cout << "[" << vec.at(x) << "] ";
}
cout << endl;
}
// assume inputs are a graph G(V,E) and latency.
// assume each vertex has a field that gives it's ASAP, ALAP time.
void FDS(Graph &g, int latency){
// DG(i) variables (probabilities per type at a given time)
// intialized to 0 and size latency constraint lambda (time)
vector<Node>::iterator k;
int num_nodes = g.vertices.size();
cout << "FDS -> NODE COUNT: " << num_nodes << endl << endl;
// loop through all the nodes to get the foce for each.
for(k = g.vertices.begin(); k != g.vertices.end(); k++){
cout << "beginning node: " << k->num << " time frame: [" << k->asap << ", " << k->alap << "]"<< endl;
// 1) cacl timeframes
// 2) calc the operation and type probabilites
// 3) calc self forces, predecessor/successor forces and total forces
// 4) schedule the operation with the least force and update its timeframe
// create DGs
vector<float> dg_mult(latency, 0);
vector<float> dg_addsub(latency, 0);
vector<float> dg_divmod(latency, 0);
vector<float> dg_logic(latency, 0);
DG(g, dg_mult, dg_addsub, dg_divmod, dg_logic);
cout << "DG_MULT: ";
printVector(dg_mult);
cout << "DG_ADD/SUB: ";
printVector(dg_addsub);
cout << "DG_DIV/MOD: ";
printVector(dg_divmod);
cout << "DG_LOGICAL: ";
printVector(dg_logic);
// calc the forces
tuple<float, int> ft = TotalForce(*k, num_nodes, dg_mult, dg_addsub, dg_divmod, dg_logic);
cout << "lowest total force: " << get<0>(ft) << " at time: " << get<1>(ft) << endl;
// schedule the node
k->fds = k->asap = k->alap = get<1>(ft);
k->scheduled = true;
cout << endl <<"SCHEDULED -> NODE: " << k->num << " FDS: " << k->fds << " ASAP: " << k->asap << " ALAP: " << k->alap << endl << endl;
// change all times for nodes connected to scheduled node
vector<Node>::iterator k2;
// loop through all nodes
for(k2 = g.vertices.begin(); k2 != g.vertices.end(); k2++){
// Nodes that have this node as a parent
// if they have the scheduled node as a parent, and there is an asap overlap, restrict it to time +1
for(unsigned int p = 0; p < k2->parent.size(); p++){
// compare the parent nodes to the scheduled node
if(k2->parent.at(p)->num == k->num){
// update the parent's status to scheduled and time frames updated in this node
k2->parent.at(p)->alap = k2->parent.at(p)->asap = k2->parent.at(p)->fds = get<1>(ft);
// if the asap and scheduled nodes times overlap
if(k2->asap <= get<1>(ft)){
// restrict it to time + 1
k2->asap = get<1>(ft) + 1;
}
}
}
// Nodes that have this node as a child
for(unsigned int p = 0; p < k2->children.size(); p++){
// compare the children nodes to the scheduled node
if(k2->children.at(p)->num == k->num){
// update the parent's status to scheduled and time frames updated in this node
k2->children.at(p)->alap = k2->children.at(p)->asap = k2->children.at(p)->fds = get<1>(ft);
// if the alap and scheduled nodes times overlap
if(k2->alap >= get<1>(ft)){
// restrict it to time + 1
k2->alap = get<1>(ft) - 1;
}
}
}
}
}// end for loop through all nodes
}
int main() {
Operation op1, op2, op3, op4;
op1.name = "MULT";
op1.type = "s";
op1.bits = 8;
op1.result = Variable("w", "s", 8);
op1.equals = "=";
op1.op1 = "*";
op1.var1 = Variable("a", "s", 8);
op1.var2 = Variable("b", "s", 8);
op2.name = "MULT";
op2.type = "s";
op2.bits = 8;
op2.result = Variable("x", "s", 8);
op2.equals = "=";
op2.op1 = "*";
op2.var1 = Variable("c", "s", 8);
op2.var2 = Variable("d", "s", 8);
op3.name = "MULT";
op3.type = "s";
op3.bits = 8;
op3.result = Variable("y", "s", 8);
op3.equals = "=";
op3.op1 = "*";
op3.var1 = Variable("e", "s", 8);
op3.var2 = Variable("f", "s", 8);
op4.name = "MULT";
op4.type = "s";
op4.bits = 8;
op4.result = Variable("z", "s", 8);
op4.equals = "=";
op4.op1 = "*";
op4.var1 = Variable("g", "s", 8);
op4.var2 = Variable("h", "s", 8);
Node n1, n2, n3, n4;
n1.num = 1;
n2.num = 2;
n3.num = 3;
n4.num = 4;
n1.operation = op1;
n2.operation = op2;
n3.operation = op3;
n4.operation = op4;
n1.asap = 1;
n2.asap = 1;
n3.asap = 2;
n4.asap = 3;
n1.alap = 2;
n2.alap = 2;
n3.alap = 3;
n4.alap = 4;
n4.parent.push_back(&n3);
n3.children.push_back(&n4);
n3.parent.push_back(&n2);
n3.parent.push_back(&n1);
n1.children.push_back(&n3);
n2.children.push_back(&n3);
Graph g;
g.vertices.push_back(n1);
g.vertices.push_back(n2);
g.vertices.push_back(n3);
g.vertices.push_back(n4);
// Call the FDS function given a Graph g, and latency l
FDS(g, 4);
}