-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.py
228 lines (155 loc) · 6.72 KB
/
GUI.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
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
from os import read
import tkinter as tk
from tkinter import ttk
from tkinter import *
import GraphReader
def openGraphs():
pass
def on_closing():
root.destroy()
def openNewWindow():
root.withdraw()
# Toplevel object which will
# be treated as a new window
global newWindow
newWindow = Toplevel(root)
newWindow.protocol("WM_DELETE_WINDOW", on_closing)
# sets the title of the
# Toplevel widget
newWindow.title("Algorithms")
# sets the geometry of toplevel
newWindow.geometry("450x350")
newWindow.configure(background='#F0F8FF')
# A Label widget to show in toplevel
Label(newWindow, text='Select Algorithm:', bg='#F0F8FF',
font=('arial', 24, 'normal')).place(x=113, y=38)
Button(newWindow, text='Back', bg='#FFA07A', font=('arial', 12, 'normal'),
command=SecondWindowBackClickFunction).place(x=10, y=10)
# This is the section of code which creates a button
Button(newWindow, text='Prim\'s', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.PrimAlgo).place(x=83-5, y=118)
# This is the section of code which creates a button
Button(newWindow, text='Kruskal', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.KruskalAlgo).place(x=193-5, y=118)
# This is the section of code which creates a button
Button(newWindow, text='Dijkstra', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.DijkstraAlgo).place(x=303-5, y=118)
# This is the section of code which creates a button
Button(newWindow, text='Bellman Ford', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.BellmanFordAlgo).place(x=83-5, y=178)
# This is the section of code which creates a button
Button(newWindow, text='Floyd Warshall', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.FloydWarshallAlgo).place(x=255-5, y=178)
# This is the section of code which creates a button
Button(newWindow, text='Clustering Coefficient', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.ClusteringCoefficientAlgo).place(x=83-5, y=238)
# This is the section of code which creates a button
Button(newWindow, text='Boruvka', bg='#FFA07A', font=('arial', 12, 'normal'),
command=GraphReader.BoruvkaAlgo).place(x=303-5, y=238)
# All Algorithm Functions
# def PrimAlgo():
# primG = GraphReader.PrimGraph(GraphReader.verts, GraphReader.starting)
# primG.graph = GraphReader.graphMat
# primG.primMST()
# openGraphs()
def DijkstraAlgo():
pass
def BellmanFordAlgo():
pass
def FloydWarshallAlgo():
pass
def BoruvkaAlgo():
pass
# All button functions
def SecondWindowBackClickFunction():
root.deiconify()
newWindow.destroy()
def TenNodeClickFunction():
input_file = "input10.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def TwentyNodeClickFunction():
input_file = "input20.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def ThirtyNodeClickFunction():
input_file = "input30.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def FortyNodeClickFunction():
input_file = "input40.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def FiftyNodeClickFunction():
input_file = "input50.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def SixtyNodeClickFunction():
input_file = "input60.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def SeventyNodeClickFunction():
input_file = "input70.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def EightyNodeClickFunction():
input_file = "input80.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def NinetyNodeClickFunction():
input_file = "input90.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
# this is the function called when the button is clicked
def HundredNodeClickFunction():
input_file = "input100.txt"
GraphReader.readInputFile(input_file)
openNewWindow()
input_file = str()
root = Tk()
# This is the section of code which creates the main window
root.geometry('450x350')
root.configure(background='#F0F8FF')
root.title('Graph Algorithms by 19K0181 and 19K1512')
# This is the section of code which creates the a label
Label(root, text='Select Input File:', bg='#F0F8FF',
font=('arial', 24, 'normal')).place(x=113, y=38)
# This is the section of code which creates a button
Button(root, text='10 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=TenNodeClickFunction).place(x=83-5, y=118)
# This is the section of code which creates a button
Button(root, text='20 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=TwentyNodeClickFunction).place(x=193-5, y=118)
# This is the section of code which creates a button
Button(root, text='30 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=ThirtyNodeClickFunction).place(x=303-5, y=118)
# This is the section of code which creates a button
Button(root, text='40 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=FortyNodeClickFunction).place(x=83-5, y=178)
# This is the section of code which creates a button
Button(root, text='50 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=FiftyNodeClickFunction).place(x=193-5, y=178)
# This is the section of code which creates a button
Button(root, text='60 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=SixtyNodeClickFunction).place(x=303-5, y=178)
# This is the section of code which creates a button
Button(root, text='70 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=SeventyNodeClickFunction).place(x=83-5, y=238)
# This is the section of code which creates a button
Button(root, text='80 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=EightyNodeClickFunction).place(x=193-5, y=238)
# This is the section of code which creates a button
Button(root, text='90 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=NinetyNodeClickFunction).place(x=303-5, y=238)
# This is the section of code which creates a button
Button(root, text='100 Nodes', bg='#FFA07A', font=('arial', 12, 'normal'),
command=HundredNodeClickFunction).place(x=193-9, y=298)
root.mainloop()