-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
595 lines (584 loc) · 28.9 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta name="author" content="Visual Rendering"/>
<meta name="description" content="Graph Algorithms visualizer project which visualizes Different types of graph algorithms such as Path-finding algorithms, Minimum Spanning Tree Algorithms, Topological Sorting"/>
<link rel="apple-touch-icon" sizes="57x57" href="favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicons/favicon-16x16.png">
<link rel="manifest" href="favicons/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<title> Graph Algorithms Visualizer </title>
<link rel="stylesheet" type="text/css" href="styles/style.css"/>
<link rel="stylesheet" href="styles/mdb.min.css" />
<script defer type="text/javascript" src="script/mdb.min.js"></script>
<script defer type="text/javascript" src="script/node.js"></script>
<script defer type="text/javascript" src="script/grid.js"></script>
<script defer type="text/javascript" src="script/bfs.js"></script>
<script defer type="text/javascript" src="script/dfs.js"></script>
<script defer type="text/javascript" src="script/dijkstra.js"></script>
<script defer type="text/javascript" src="script/astar.js"></script>
<script defer type="text/javascript" src="script/bidirectional.js"></script>
<script defer type="text/javascript" src="script/greedybest.js"></script>
<script defer type="text/javascript" src="script/common.js"></script>
<script defer type="text/javascript" src="script/primmazegenerator.js"></script>
<script defer type="text/javascript" src="script/recursivebacktracker.js"></script>
<script defer type="text/javascript" src="script/app.js"></script>
<script defer type="text/javascript" src="script/vertix.js"></script>
<script defer type="text/javascript" src="script/canvas.js"></script>
<script defer type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis-network.min.css" rel="stylesheet" type="text/css" />
<script defer type="text/javascript" src="script/network.js"></script>
</head>
<body>
<!-- Tabs navs -->
<ul class="nav nav-tabs nav-justified " id="tabs" role="tablist">
<li class="nav-item" role="presentation">
<a
class="nav-link active"
id="path-finder"
data-toggle="tab"
href="#path-finder-tab"
role="tab"
aria-controls="ex3-tabs-1"
aria-selected="true"
>Path finding Algorithms</a
>
</li>
<li class="nav-item" role="presentation">
<a
class="nav-link"
id="minimum-spanning-tree"
data-toggle="tab"
href="#minimum-spanning-tree-tab"
role="tab"
aria-controls="ex3-tabs-2"
aria-selected="false"
>Minimum Spanning Trees</a
>
</li>
<li class="nav-item" role="presentation">
<a
class="nav-link"
id="topological-sort"
data-toggle="tab"
href="#topological-sort-tab"
role="tab"
aria-controls="ex3-tabs-3"
aria-selected="false"
>Topological Sorting</a
>
</li>
</ul>
<!-- Tabs navs -->
<!-- Tabs content -->
<div class="tab-content" id="ex2-content">
<div
class="tab-pane fade show active"
id="path-finder-tab"
role="tabpanel"
aria-labelledby="ex3-tab-1"
>
<header>
<nav class="buttons-container navbar navbar-expand-lg navbar-dark bg-dark">
<!-- Container wrapper -->
<div class="container-fluid">
<!-- Navbar brand -->
<a class="navbar-brand" >Path-Finding Algorithms</a>
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon" id="breakpoint-toggler"></span>
</button>
<!-- Collapsible wrapper -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left links -->
<ul class="navbar-nav ml-auto mb-2 mb-lg-0">
<li class="nav-item">
<!-- <a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li> -->
<!-- Navbar dropdown -->
<div class="btn-group shadow-5">
<button
type="button"
class="btn btn-outline-info mr-2 dropdown-toggle mt-2"
data-ripple-color="dark"
id="path-finding-grp-btn"
data-toggle="dropdown"
aria-expanded="false"
>
Path Finding Algorithms
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" id="dfs">DFS</a></li>
<li><a class="dropdown-item" id="bfs">BFS</a></li>
<li><a class="dropdown-item" id="dijkstra">Dijkstra (UCS)</a></li>
<li><a class="dropdown-item" id="bidirectional-bfs">Bidirectional BFS</a></li>
<li><a class="dropdown-item" id="bidirectional-dijkstra">Bidirectional Dijkstra (UCS)</a></li>
<!-- <li><hr class="dropdown-divider" /></li> -->
<li><a class="dropdown-item" id="astar">A* (Manhattan Distance)</a></li>
<li><a class="dropdown-item" id="greedybest">Greedy Best-first (Manhattan Distance)</a></li>
<li><a class="dropdown-item" id="bidirectional-astar">Bidirectional A*</a></li>
<li><a class="dropdown-item" id="bidirectional-greedy-bfs">Bidirectional Greedy Best-first</a></li>
</ul>
</div>
<div class="btn-group shadow-0">
<button
type="button"
class="btn btn-outline-info mr-2 dropdown-toggle mt-2"
data-toggle="dropdown"
id="maze-generation-grp-btn"
aria-expanded="false"
>
Random Maze Generation Algorithms
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" id="maze-recursive-backtracker">Recursive Backtracker (real-time)</a></li>
<li><a class="dropdown-item" id="maze-prim">Prim's Algorithm (real-time)</a></li>
<!-- <li><hr class="dropdown-divider" /></li> -->
<li><a class="dropdown-item" id="maze-animation-recursive-backtracker">Animated Recurisve Backtracker</a></li>
<li><a class="dropdown-item" id="maze-prim-animation">Animated Prim's Algorithm</a></li>
</ul>
</div>
<li class="nav-item" >
<button
disabled
type="button"
class="btn btn-outline-danger mr-2 ml-1 mt-2"
data-ripple-color="light"
id="visualize"
>
Visualize
</button>
</li>
<li class="nav-item">
<button id="clear-path" disabled type="button" class="btn btn-outline-warning mr-2 ml-1 mt-2" data-ripple-color="light">
Clear Path
</button>
</li>
<li class="nav-item">
<button id="clear" disabled type="button" class="btn btn-outline-warning mr-2 ml-1 mt-2" data-ripple-color="light">
Clear All
</button>
</li>
</ul>
<li class="nav-item">
<label class="text-warning" for="grid-size"> Node Size: </label>
<input name="grid-size" type="range" class="form-range" id="size-slider" value="28" min="19" max="90" />
</li>
</div>
<!-- Collapsible wrapper -->
</div>
<!-- Container wrapper -->
</nav>
</header>
<main>
<section id="grid-container">
</section>
</main>
</div>
<div
class="tab-pane fade"
id="minimum-spanning-tree-tab"
role="tabpanel"
aria-labelledby="ex3-tab-2"
>
<header>
<nav class="buttons-container navbar navbar-expand-lg navbar-dark bg-dark">
<!-- Container wrapper -->
<div class="container-fluid">
<!-- Navbar brand -->
<a class="navbar-brand" >Minimum Spanning Tree</a>
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon" id="breakpoint-toggler"></span>
</button>
<!-- Collapsible wrapper -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left links -->
<ul class="navbar-nav ml-auto mb-2 mb-lg-0">
<li class="nav-item">
<!-- <a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li> -->
<!-- <li class="nav-item" >
<button
type="button"
class="btn btn-outline-danger mr-2 ml-1 mt-2"
data-ripple-color="light"
id="generate-mst"
>
Generate Random MST
</button>
</li> -->
<li class="nav-item">
<button id="clear-canvas" type="button" class="btn btn-outline-warning mr-4 ml-1 mt-2" data-ripple-color="light">
Clear Canvas
</button>
</li>
</ul>
<li class="nav-item">
<label class="text-warning" for="nodes-amount"> Generate Random: </label>
<input name="nodes-amount" type="range" class="form-range" id="nodes-slider" value="25" min="10" max="75" />
</li>
</div>
<!-- Collapsible wrapper -->
</div>
<!-- Container wrapper -->
</nav>
</header>
<main>
<section id="canvas-helper">
<div>
<div id="mst-helper">
<p class="lead">You can <span>start drawing the <abbr title="Minimum Spanning Tree">MST</abbr> by clicking on canvas.</p>
<p class="text-muted"><kbd>Click</kbd> to <u><b>Add</b></u> | <kbd>Right-Click</kbd> to <u><b>Remove</b></u>.</p>
<p class="text-muted">Generated by <b><u>Prim's Algorithm</u></b> using <b><u>Euclidean Distances</b></u> as weights of graph</p>
</div>
<div class="accordion" id="mst-definition">
<div id="headingOne">
<h2>
<button
class="btn btn-link btn-block text-left pl-3"
type="button"
data-toggle="collapse"
data-target="#collapseOne"
aria-expanded="true"
aria-controls="collapseOne"
>
Minimum Spanning Tree
</button>
</h2>
</div>
<div
id="collapseOne"
class="collapse pl-3"
aria-labelledby="headingOne"
data-parent="#mst-definition"
>
<blockquote class="blockquote" cite="https://en.wikipedia.org/wiki/Minimum_spanning_tree#:~:text=A%20minimum%20spanning%20tree%20(MST,minimum%20possible%20total%20edge%20weight.&text=There%20are%20quite%20a%20few%20use%20cases%20for%20minimum%20spanning%20trees.">
<p>A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected,
edge-weighted undirected graph that connects all the vertices together,
without any cycles and with the minimum possible total edge weight.
That is, it is a spanning tree whose sum of edge weights is as small as possible.</p>
</blockquote>
</div>
</div>
</div>
</section>
<section id="canvas-container">
</section>
</main>
</div>
<div
class="tab-pane fade"
id="topological-sort-tab"
role="tabpanel"
aria-labelledby="ex3-tab-3"
>
<header>
<nav class="buttons-container navbar navbar-expand-lg navbar-dark bg-dark">
<!-- Container wrapper -->
<div class="container-fluid">
<!-- Navbar brand -->
<a class="navbar-brand" >Topological Sort</a>
<!-- Toggle button -->
</div>
<!-- Container wrapper -->
</nav>
</header>
<main>
<section id="network-helper">
<div>
<div id="topological-helper">
<p class="lead">Task Scheduling can be done via <em>Topological Sorting</em>.</p>
<p class="text-muted">Topological Sorting is applicable only on <abbr title="Directed Acyclic Graphs">DAGs</abbr>.</p>
<p class="text-muted"><em>Topological Sorting</em> by <b><u>Kahn's Algorithm</u></b> using List of tasks below</p>
</div>
<div class="accordion" id="topological-sort-definition">
<div id="headingOne">
<h2>
<button
class="btn btn-link btn-block text-left pl-3"
type="button"
data-toggle="collapse"
data-target="#collapseOne"
aria-expanded="true"
aria-controls="collapseOne"
>
Topological Sorting
</button>
</h2>
</div>
<div
id="collapseOne"
class="collapse pl-3"
aria-labelledby="headingOne"
data-parent="#topological-sort-definition"
>
<blockquote class="blockquote" cite="https://en.wikipedia.org/wiki/Topological_sorting#:~:text=In%20computer%20science%2C%20a%20topological,before%20v%20in%20the%20ordering.">
<p>In computer science, a topological sort or topological ordering of a directed graph is
a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u
comes before v in the ordering.
For instance, the vertices of the graph may represent tasks to be performed,
and the edges may represent constraints that one task must be performed before
another; in this application, a topological ordering is just a valid sequence
for the tasks. A topological ordering is possible if and only if the graph has
no directed cycles, that is, if it is a directed acyclic graph (DAG)
</p>
</blockquote>
</div>
</div>
</div>
</section>
<section id="network-container">
<form name="tasks">
<div id="tasks-input">
<div id="task-1-input" class="row g-3 align-items-center mt-1 ml-2">
<div class="form-outline col-auto mb-2 mr-2">
<input
type="text"
name="task-1"
class="form-control"
placeholder="Buy Groceries"
aria-describedby="task-1"
required
/>
<label class="form-label" for="task-1">Task #1</label>
</div>
<div class="form-outline col-auto">
<input
type="text"
name="preq-1"
class="form-control"
placeholder="Dress"
aria-describedby="preq-1"
required
/>
<label class="form-label" for="preq-1">Task #1 Prerequisites</label>
</div>
<div class="col-auto">
<span id="textExample2" class="form-text mb-3">
Prerequisites Must be comma separated Values
</span>
</div>
</div>
<div id="task-2-input" hidden class="row g-3 align-items-center ml-2">
<div class="form-outline col-auto mb-2 mr-2">
<input
type="text"
name="task-2"
class="form-control"
placeholder="Dress"
aria-describedby="task-1"
required
/>
<label class="form-label" for="task-2">Task #2</label>
</div>
<div class="form-outline mb-2 col-auto">
<input
type="text"
name="preq-2"
class="form-control"
placeholder="Wakeup"
aria-describedby="preq-1"
required
/>
<label class="form-label" for="preq-2">Task #2 Prerequisites</label>
</div>
</div>
<div id="task-3-input" hidden class="row g-3 align-items-center ml-2">
<div class="form-outline col-auto mb-2 mr-2">
<input
type="text"
name="task-3"
placeholder="Wakeup"
class="form-control"
aria-describedby="task-1"
required
/>
<label class="form-label" for="task-1">Task #3</label>
</div>
<div class="form-outline mb-2 col-auto">
<input
type="text"
name="preq-3"
placeholder="Sleep"
class="form-control"
aria-describedby="preq-1"
required
/>
<label class="form-label" for="preq-3">Task #3 Prerequisites</label>
</div>
</div>
<div id="task-4-input" hidden class="row g-3 align-items-center ml-2">
<div class="form-outline col-auto mb-2 mr-2">
<input
type="text"
name="task-4"
placeholder="You're still here?"
class="form-control"
aria-describedby="task-1"
required
/>
<label class="form-label" for="task-4">Task #4</label>
</div>
<div class="form-outline mb-2 col-auto border">
<input
type="text"
name="preq-4"
class="form-control"
placeholder="I'm out of ideas"
aria-describedby="preq-1"
required
/>
<label class="form-label" for="preq-1">Task #4 Prerequisites</label>
</div>
</div>
<div id="task-5-input" hidden class="row g-3 align-items-center ml-2">
<div class="form-outline col-auto mb-2 mr-2">
<input
type="text"
name="task-5"
class="form-control"
placeholder="Let's finish it with a cycle"
aria-describedby="task-1"
required
/>
<label class="form-label" for="task-1">Task #5</label>
</div>
<div class="form-outline mb-2 col-auto">
<input
type="text"
name="preq-5"
class="form-control"
placeholder="Let's finish it with a cycle"
aria-describedby="preq-1"
required
/>
<label class="form-label" for="preq-1">Task #5 Prerequisites</label>
</div>
</div>
</div>
<!-- Submit button -->
<div id="tasks-submit" class="mb-2">
<button id="task-adder" class="btn btn-danger ml-2 mt-2">
Add more
</button>
<button id="network-visualizer" class="btn btn-danger mt-2">
Visualize
</button>
</div>
</form>
<div id="result"></div>
<div id="mynetwork"></div>
</section>
</main>
</div>
</div>
<!-- Tabs content -->
<div id="shortcut-toast" class="toast bg-info text-white" role="alert" aria-live="assertive"
aria-atomic="true" data-autohide="false" data-content="11000">
<div class="toast-header bg-info text-white">
<i class="fas fa-info-circle fa-lg mr-2"></i>
<strong class="mr-auto">Path-Finder</strong>
<!-- <button type="button" class="ml-2 my-1 close text-white" data-dismiss="toast"
aria-label="Close">
<span aria-hidden="true">×</span>
</button> -->
</div>
<div class="toast-body">
<b><u>Click/Hover</u></b> on icons to see <u><b>Shortcuts</u></b>
</div>
</div>
<div id="fail-kahn-toast" class="toast bg-danger text-white" role="alert" aria-live="assertive"
aria-atomic="true" data-autohide="false">
<div class="toast-header bg-danger text-white">
<i class="fas fa-exclamation-triangle fa-lg mr-2"></i>
<strong class="mr-auto">Topological Sort</strong>
<!-- <button type="button" class="ml-2 my-1 close text-white" data-dismiss="toast"
aria-label="Close">
<span aria-hidden="true">×</span>
</button> -->
</div>
<div class="toast-body">
<b>Failed</b> to do <em>Topological Sort</em>, there exists a <b><u>Cycle</b></u>.
</div>
</div>
<div id="prim-toast" class="toast bg-info text-white" role="alert" aria-live="assertive"
aria-atomic="true" data-autohide="false" data-content="11000">
<div class="toast-header bg-info text-white">
<i class="fas fa-info-circle fa-lg mr-2"></i>
<strong class="mr-auto">Minimum-Spanning Tree</strong>
<!-- <button type="button" class="ml-2 my-1 close text-white" data-dismiss="toast"
aria-label="Close">
<span aria-hidden="true">×</span>
</button> -->
</div>
<div class="toast-body">
Uses <b><u>Prim's Algorithm</u></b> for MST and <u><em><b>Euclidean Distance</b></em></u> for <b>weights</b>
</div>
</div>
<div id="info-toast" class="toast bg-success text-white" role="alert" aria-live="assertive"
aria-atomic="true" data-autohide="false">
<div class="toast-header bg-success text-white">
<i class="fas fa-info-circle fa-lg mr-2"></i>
<strong class="mr-auto">Path-Finder</strong>
<button type="button" class="ml-2 my-1 close text-white" data-dismiss="toast"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="toast-body">
You can <b><u>Drag</u></b> <b>Start</b> or <b>End</b> to see how path is affected in realtime
</div>
</div>
<!-- Danger toast -->
<div id="fail-toast" class="toast bg-danger text-white" data-autohide="false" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header bg-danger text-white">
<i class="fas fa-exclamation-triangle fa-lg mr-2"></i>
<strong class="mr-auto">Path-Finder</strong>
<button type="button" class="ml-2 my-1 close text-white" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="toast-body">
Sorry, I wasn't able to find End Node
</div>
</div>
</body>
</html>