-
Notifications
You must be signed in to change notification settings - Fork 0
/
nextdate.dot
116 lines (103 loc) · 4.3 KB
/
nextdate.dot
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
digraph nextdate {
ranksep=0.1
graph [rankdir = "TB"];
node [fontsize=16,fixedsize=true,width=0.7,shape=circle];
Start [fontcolor="black", fillcolor="lightgray", style=filled];
End [fontcolor="black", fillcolor="lightgray", style=filled];
Err0 [fontcolor="red", fillcolor="lightgray", style=filled];
Err1 [fontcolor="red", fillcolor="lightgray", style=filled];
Err2 [fontcolor="red", fillcolor="lightgray", style=filled];
Err3 [fontcolor="red", fillcolor="lightgray", style=filled];
Err4 [fontcolor="red", fillcolor="lightgray", style=filled];
Start -> 29;
//Restrictions that the year must have the following invariant: 1801 <= year <= 2021
29 [width=1.1 shape=diamond]
29 -> 30 [label = "T" color="blue"];
30 -> Err0;
//these variables will hold the proper values for the nextDate's day, month, and year values, respectively
29 -> "33~35" [label = "F" color="red"]; // F
"33~35" -> 38;
//Is this month with 31 days?
38 [width=1.1 shape=diamond]
38 -> 40 [label = "T" color="blue"]; // T
40 [width=1.1 shape=diamond]
40 -> 41 [label = "T" color="blue"]; // F
41 -> 103;
40 -> "43~44" [label = "F" color="red"]; // F
"43~44" -> 103;
38 -> 48 [label = "F" color="red"];
//is this month a month with 30 days?
48 [width=1.1 shape=diamond]
48 -> 50 [label = "T" color="blue"];
50 [width=1.1 shape=diamond]
50 -> 51 [label = "T" color="blue"];
51 -> 103;
50 -> 53 [label = "F" color="red"];
53 [width=1.1 shape=diamond]
53 -> "54~55" [label = "T" color="blue"];
"54~55" -> 103;
53 -> 58 [label = "F" color="red"];
58 -> Err1;
48 -> 62 [label = "F" color="red"];
//is this month December?
62 [width=1.1 shape=diamond]
62 -> 64 [label = "T" color="blue"]; // T
64 [width=1.1 shape=diamond]
64 -> 65 [label = "T" color="blue"]; // T
65 -> 103;
64 -> "67~68" [label = "F" color="red"]; // F
"67~68" -> 69;
69 [width=1.1 shape=diamond]
69 -> 70 [label = "T" color="blue"]; // T
70 -> Err2;
69 -> 72 [label = "F" color="red"]; // F
72 -> 103;
62 -> 77 [label = "F" color="red"];
//is this month February? we need to check for leap years and such
77 [width=1.1 shape=diamond]
77 -> 79 [label = "T" color="blue"]; // T
79 [width=1.1 shape=diamond]
79 -> 80 [label = "T" color="blue"]; //T
80 -> 103;
79 -> 82 [label = "F" color="red"]; // F
82 [width=1.1 shape=diamond]
82 -> 83 [label = "T" color="blue"]; //T
83 [width=1.1 shape=diamond]
83 -> 84 [label = "T" color="blue"]; // T
84 -> 103;
83 -> "86~87" [label = "F" color="red"]; //F
"86~87" -> 103;
82 -> 90 [label = "F" color="red"]; //F
90 [width=1.1 shape=diamond]
90 -> 91 [label = "T" color="blue"]; //T
91 [width=1.1 shape=diamond]
91 -> "92~93" [label = "T" color="blue"]; //T
"92~93" -> 103;
91 -> 96 [label = "F" color="red"]; //F
96 -> Err3;
90 -> 98 [label = "F" color="red"]; //F
91 [width=1.1 shape=diamond]
98 -> 99 [label = "T" color="blue"]; //T
99 -> Err4;
98 -> 103 [label = "F" color="red"]; // F
// anything else.
77 -> 103 [label = "F" color="red"]; // F
//return the string representing the nextDate, in the form MM/DD/YY
103 -> End;
// Errors
Err0 -> End;
Err1 -> End;
Err2 -> End;
Err3 -> End;
Err4 -> End;
// ranking
{ rank = same; 30; "33~35";}
{ rank = same; 40; 48;}
{ rank = same; 50; 62; 41; "43~44"}
{ rank = same; 64; 77; 53; 51;}
{ rank = same; "54~55"; 58; 65; 79; "67~68";}
{ rank = same; 69; 82; 80;}
{ rank = same; 70; 72; 83; 90}
{ rank = same; 84; "86~87"; 91; 98}
{ rank = same; "Err0"; "Err1"; "Err2", "Err3"; "Err4"}
}