-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgraphs.html
541 lines (518 loc) · 22.6 KB
/
graphs.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Graphs - AlgoVis.io</title>
<meta
content="AlgoVis is an online algorithm visualization tool."
name="description"
/>
<meta content="algorithm visualization tool online" name="keywords" />
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon" />
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon" />
<!-- Google Fonts -->
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i"
rel="stylesheet"
/>
<!-- Vendor CSS Files -->
<link
href="assets/vendor/bootstrap/css/bootstrap.min.css"
rel="stylesheet"
/>
<link href="assets/vendor/icofont/icofont.min.css" rel="stylesheet" />
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet" />
<link href="assets/vendor/venobox/venobox.css" rel="stylesheet" />
<link
href="assets/vendor/owl.carousel/assets/owl.carousel.min.css"
rel="stylesheet"
/>
<link href="assets/vendor/aos/aos.css" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/main.css" />
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet" />
</head>
<body>
<!-- ======= Top Bar ======= -->
<div
id="topbar"
class="d-none d-lg-flex align-items-center fixed-top header-inner-pages"
>
<div class="container-fluid d-flex">
<div class="contact-info mr-auto"></div>
<div class="social-links">
<a href="https://twitter.com/tobiasnoethlich" class="twitter">
<i class="icofont-twitter"> </i>
</a>
<a href="https://github.com/tobinatore" class="github">
<i class="icofont-github"> </i>
</a>
<a
href="https://www.xing.com/profile/Tobias_Noethlich/cv"
class="xing"
>
<i class="icofont-xing"> </i>
</a>
<a
href="https://www.linkedin.com/in/tobias-noethlich/"
class="linkedin"
>
<i class="icofont-linkedin"> </i>
</a>
</div>
</div>
</div>
<!-- ======= Header ======= -->
<header id="header" class="fixed-top header-inner-pages">
<div class="container-fluid d-flex align-items-center">
<a class="btn back-button mr-4" href="index.html#categories"
><i class="bx bx-arrow-back white-text" aria-hidden="true"></i>
Back</a
>
<h1 class="logo mr-auto"><a href="index.html">Algovis.io</a></h1>
<!-- Uncomment below if you prefer to use an image logo -->
<!-- <a href="index.html" class="logo mr-auto"><img src="assets/img/logo.png" alt="" class="img-fluid"></a>-->
<nav class="nav-menu d-none d-lg-block">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#overview">Overview</a></li>
<li><a href="#traversal">Traversal</a></li>
<li><a href="#mst">MST</a></li>
<li><a href="#other">Others</a></li>
</ul>
</nav>
<!-- .nav-menu -->
</div>
</header>
<!-- End Header -->
<main id="main">
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container-fluid">
<ol>
<li><a href="index.html">Home</a></li>
<li>Graphs</li>
</ol>
<h2>Graph algorithms</h2>
</div>
</section>
<!-- End Breadcrumbs -->
<section class="inner-page">
<section id="overview" class="pt-0">
<div class="container">
<h3 class="highlighted-text">Overview</h3>
<div class="mb-4 explanation ml-2 mr-2" style="font-size: large">
<p>
A graph is a structure amounting to a set of objects in which
some pairs of the objects are in some sense "related".
<br /><br />
They consist of a fixed number of vertices (or nodes), which
represent the data points and edges, which show the relation
between vertices. These edges can be directed or undirected.
<br /><br />For example, if the vertices represent people at a
party, and there is an edge between two people if they shake
hands, then this graph is undirected because any person A can
shake hands with a person B only if B also shakes hands with A.
In contrast, if any edge from a person A to a person B
corresponds to A owes money to B, then this graph is directed,
because owing money is not necessarily reciprocated. The former
type of graph is called an undirected graph while the latter
type of graph is called a directed graph. <br /><br />Typically,
a graph is depicted in diagrammatic form as a set of dots or
circles for the vertices, joined by lines or curves for the
edges.
</p>
</div>
</div>
<div class="container-fluid">
<div class="row mt-5 highlighted-text">
<div class="col-sm-12 text-center"><h2>Search</h2></div>
</div>
<div class="row justify-content-center mt-2">
<div class="col-sm-12 col-md-10 col-lg-8">
<form class="card card-sm border-red">
<div class="card-body row no-gutters align-items-center">
<div class="col-auto">
<i class="bx bx-search-alt-2 h4 text-body"></i>
</div>
<!--end of col-->
<div class="col">
<input
id="search"
class="form-control form-control-borderless"
type="search"
placeholder="Search names or keywords"
/>
</div>
<!--end of col-->
<!--end of col-->
</div>
</form>
</div>
<!--end of col-->
</div>
</div>
</section>
<!-- GRAPH TRAVERSAL -->
<section id="traversal">
<div class="container-fluid w-100">
<!-- Gradient divider -->
<hr data-content="Graph traversal" class="hr-text mb-2 cd-hide" />
<div class="w-100 p-2 row mt-3 mb-3 cd-hide">
<div class="col-sm-1 col-md-1 col-lg-3"></div>
<div class="explanation col-sm-10 col-md-10 col-lg-6">
A graph traversal algorithm visits every vertex it can reach
from its starting point, effectively traversing the entire graph
if there are no disconnected vertices.
</div>
<div class="col-sm-1 col-md-1 col-lg-3"></div>
</div>
<div class="card-deck mb-4 cd-hide">
<div
id="breadth-first search bfs"
class="algorithm shadow-highlight card"
>
<a href="bfs.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Breadth-first search</h5>
<h6 class="card-subtitle">Graph traversal</h6>
<p class="card-text">
Breadth-first search starts at the root node (or any
specified node) and explores all of the neighbor nodes at
the present depth prior to moving on to the nodes at the
next depth level. <br /><br />
<b>Time Complexity:</b>  <i>O(|V|+|E|)</i><br />
<b>Space Complexity:</b>  <i>O(|V|)</i>
</p>
</div>
</a>
</div>
<div
id="depth-first search dfs"
class="algorithm shadow-highlight card"
>
<a href="dfs.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Depth-first search</h5>
<h6 class="card-subtitle">Graph traversal</h6>
<p class="card-text">
Depth-first search starts at the root node (or any
specified node) and explores the node branch as far as
possible before being forced to backtrack and expand other
nodes. <br /><br />
<b>Time Complexity:</b>  <i>O(|V|+|E|)</i><br />
<b>Space Complexity:</b>  <i>O(|V|)</i>
</p>
</div>
</a>
</div>
</div>
<div id="results"></div>
</div>
</section>
<!-- MST -->
<section id="mst">
<div class="container-fluid w-100">
<!-- Gradient divider -->
<hr data-content="Minimum spanning tree" class="hr-text cd-hide" />
<div
class="w-50 p-2 rounded explanation row ml-auto mr-auto mt-2 mb-3 cd-hide"
>
<div class="col-sm-12">
A minimum spanning tree (MST) 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.
</div>
</div>
<div class="card-deck mb-4 cd-hide">
<div
id="prim's algorithm prims algorithm"
class="algorithm shadow-highlight card"
>
<a href="prims.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Prim's algorithm</h5>
<h6 class="card-subtitle">Minimum spanning tree</h6>
<p class="card-text">
Prim's algorithm operates by building the MST one vertex
at a time, from an arbitrary starting vertex, at each step
adding the cheapest possible connection from the tree to
another vertex. <br /><br />
<b>Time Complexity:</b><br />
<b>adjacency matrix:</b> <i>O(|V|²)</i><br />
<b>binary heap & adjacency list:</b> 
<i>O(|E|log|V|)</i><br />
<b>fibonacci heap & adjacency list:</b> 
<i>O(|E|+|V|log|V|)</i>
</p>
</div>
</a>
</div>
<div
id="kruskal's algorithm kruskals algorithm"
class="algorithm shadow-highlight card"
>
<a href="kruskals.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Kruskal's algorithm</h5>
<h6 class="card-subtitle">Minimum spanning tree</h6>
<p class="card-text">
Kruskal's algorithm works by stepping through all edges
and adding the next lowest-weight edge that will not form
a cycle to the MST. <br /><br />
<b>Time Complexity:</b>  <i>O(|E|+|V|log|V|)</i>
</p>
</div>
</a>
</div>
</div>
</div>
</section>
<!-- SCC -->
<section id="scc">
<div class="container-fluid w-100">
<!-- Gradient divider -->
<hr
data-content="Strongly connected components"
class="hr-text cd-hide"
/>
<div
class="w-50 p-2 rounded explanation row ml-auto mr-auto mt-2 mb-3 cd-hide"
>
<div class="col-sm-12">
A strongly connected component is a subset of vertices such that
any two vertices of this subset are reachable from each other.
</div>
</div>
<div class="card-deck mb-4 cd-hide">
<div
id="kosaraju's algorithm kosarajus algorithm"
class="algorithm shadow-highlight card"
>
<a href="kosarajus.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Kosaraju's algorithm</h5>
<h6 class="card-subtitle">Strongly connected components</h6>
<p class="card-text">
Kosaraju's algorithm is a DFS based algorithm used to find
Strongly Connected Components (SCC) in a graph. It is
based on the idea that if one is able to reach a vertex v
starting from vertex u, then one should be able to reach
vertex u starting from vertex v and if such is the case,
one can say that vertices u and v are strongly connected -
they are in a strongly connected sub-graph. <br /><br />
<b>Time Complexity:</b><br />
<b>adjacency matrix:</b> <i>O(|V|²)</i><br />
<b>adjacency list:</b>  <i>O(|E|+|V|)</i>
</p>
</div>
</a>
</div>
<div
id="tarjan's algorithm tarjans algorithm"
class="algorithm shadow-highlight card"
>
<a href="tarjans.html" class="unstyled-link">
<div class="card-body">
<h5 class="card-title">Tarjan's algorithm</h5>
<h6 class="card-subtitle">Strongly connected components</h6>
<p class="card-text">
Tarjan's algorithm is based on depth first search (DFS).
The vertices are indexed as they are traversed by the DFS
procedure. While returning from the recursion of DFS,
every vertex V gets assigned a vertex L as a
representative. L is a vertex with the least index that
can be reach from V. Nodes with the same representative
assigned are located in the same strongly connected
component. <br /><br />
<b>Time Complexity:</b><br />
<i>O(|E|+|V|)</i>
</p>
</div>
</a>
</div>
</div>
</div>
</section>
</section>
</main>
<!-- ======= Footer ======= -->
<footer id="footer">
<div class="footer-top">
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-6">
<div class="footer-info">
<h3>AlgoVis.io</h3>
<strong>Email:</strong> [email protected]<br />
<div class="social-links mt-3">
<a href="https://twitter.com/tobiasnoethlich" class="twitter"
><i class="icofont-twitter"></i
></a>
<a href="https://github.com/tobinatore" class="github"
><i class="icofont-github"></i
></a>
<a
href="https://www.xing.com/profile/Tobias_Noethlich/cv"
class="xing"
><i class="icofont-xing"></i
></a>
<a
href="https://www.linkedin.com/in/tobias-noethlich/"
class="linkedin"
><i class="icofont-linkedin"></i
></a>
</div>
</div>
</div>
<div class="col-lg-2 col-md-6 footer-links"></div>
<div class="col-lg-2 col-md-6 footer-links">
<h4>Useful Links</h4>
<ul>
<li>
<i class="bx bx-chevron-right"></i>
<a href="index.html">Home</a>
</li>
<li>
<i class="bx bx-chevron-right"></i>
<a href="index.html#about">About us</a>
</li>
<li>
<i class="bx bx-chevron-right"></i>
<a href="index.html#categories">Categories</a>
</li>
<li>
<i class="bx bx-chevron-right"></i>
<a href="#">Terms of service</a>
</li>
<li>
<i class="bx bx-chevron-right"></i>
<a href="privacypolicy.html">Privacy policy</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="copyright">
© Copyright <strong><span>AlgoVis.io</span></strong
>. All Rights Reserved
</div>
<div class="credits">
<!-- All the links in the footer should remain intact. -->
<!-- You can delete the links only if you purchased the pro version. -->
<!-- Licensing information: https://bootstrapmade.com/license/ -->
<!-- Purchase the pro version with working PHP/AJAX contact form: https://bootstrapmade.com/day-multipurpose-html-template-for-free/ -->
Designed by <a href="https://bootstrapmade.com/">BootstrapMade</a>
</div>
</div>
</footer>
<!-- End Footer -->
<a href="#" class="back-to-top"><i class="icofont-simple-up"></i></a>
<div id="preloader"></div>
<!-- Vendor JS Files -->
<script src="assets/vendor/jquery/jquery.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/venobox/venobox.min.js"></script>
<script src="assets/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="assets/vendor/aos/aos.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<script>
const $body = $("body");
const $header = $(".page-header");
const $navCollapse = $(".navbar-collapse");
const scrollClass = "scroll";
$(".card-subtitle").hide();
$(window).on("scroll", () => {
// Color background of navbar a solid red on scroll
if (this.matchMedia("(min-width: 992px)").matches) {
const scrollY = $(this).scrollTop();
scrollY > 0
? $body.addClass(scrollClass)
: $body.removeClass(scrollClass);
} else {
$body.removeClass(scrollClass);
}
});
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
// when clicking a link in the navbar scroll smoothly to the anchor
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
});
});
});
function showRelevant(name = "") {
/*************************************************************/
/* This function selects the algorithms fitting to the users */
/* search terms and displays them. */
/* */
/* Input: name (string) - the input of the search field */
/*************************************************************/
if (name == "") {
// search bar is empty -> show every algorithm and clear results <div>
$(".cd-hide").show();
$(".card-subtitle").hide();
$("#results").empty();
} else {
// Since I'm updating the results on every letter the user enters,
// it's important to clear the results <div>, so therea are no duplicates
// or no longer relevant algorithms displayed.
$("#results").empty();
$(".card-subtitle").show();
$(".cd-hide").hide();
let algoList = $('.algorithm[id*="' + name.toLowerCase() + '"]');
let deckString = '<div class="card-deck mb-4">';
let lastFilled = algoList.length % 4;
if (algoList.length != 0) {
// Due to each card-deck being a different a different entity I can't
// simply hide the algorithms which aren't needed, as this causes
// a linebreak betwenn algorithms with different parent elements.
// ------------------------------------------------------------------
// A solution for this is to grab the algorithms needed and append
// them all to a new <div>.
// Loop over the list of elements and build the content of the new <div>
for (let i = 0; i < algoList.length; i++) {
// 4 algorithms on every row --> close the current card-deck after
// 4 algorithms are processed and open a new one.
if ((i + 1) % 4 == 0) {
deckString +=
algoList[i].outerHTML + '</div><div class="card-deck mb-4">';
} else {
deckString += algoList[i].outerHTML;
}
}
// if the last row is not completely filled,
// fill it with hidden elements so the visible
// cards are the right size
if (lastFilled != 0) {
for (let j = 0; j < 4 - lastFilled; j++) {
element = algoList[0].cloneNode(true);
element.style.visibility = "hidden";
deckString += element.outerHTML;
}
}
// Closing the las card-deck and filling the <div> with the results
// of the users search term.
deckString += "</div>";
$("#results").append(deckString);
} else {
$("#results").append(`No results matching ${name}.`);
}
}
}
$("#search").on("input", function (e) {
showRelevant(this.value);
});
</script>
</body>
</html>