Skip to content

Commit 1ef17da

Browse files
committed
first commit
0 parents  commit 1ef17da

File tree

361 files changed

+2164
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

361 files changed

+2164
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Algorithm Visualizer
2+
http://parkjs814.github.io/AlgorithmVisualizer

algorithm/category.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"graph_search": {
3+
"name": "Graph Search",
4+
"list": {
5+
"dfs": "DFS",
6+
"bfs": "BFS"
7+
}
8+
}
9+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"def": "Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking.",
3+
"apps": [
4+
"Finding connected components.",
5+
"Topological sorting.",
6+
"Finding 2-(edge or vertex)-connected components.",
7+
"Finding 3-(edge or vertex)-connected components.",
8+
"Finding the bridges of a graph.",
9+
"Generating words in order to plot the Limit Set of a Group.",
10+
"Finding strongly connected components.",
11+
"Planarity testing",
12+
"Solving puzzles with only one solution, such as mazes. (DFS can be adapted to find all solutions to a maze by only including nodes on the current path in the visited set.)",
13+
"Maze generation may use a randomized depth-first search.",
14+
"Finding biconnectivity in graphs."
15+
],
16+
"cpx": {
17+
"time": "O(|E|)",
18+
"space": "O(|V|)"
19+
},
20+
"refs": [
21+
"https://en.wikipedia.org/wiki/Depth-first_search"
22+
],
23+
"files": {
24+
"sample1": "Visiting all connected nodes without making any circuit",
25+
"sample2": "Going through all paths without making any circuit"
26+
}
27+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var D; // D[i] indicates whether the i-th node is discovered or not
2+
3+
function DFS(v, p) { // v = current node, p = previous node
4+
tracer.visit(v, p);
5+
D[v] = true; // label v as discovered
6+
G[v].forEach(function (w) { // G[v] contains edges starting from v
7+
if (!D[w]) { // if w is not labeled as discovered
8+
DFS(w, v); // recursively call DFS
9+
}
10+
});
11+
tracer.leave(v, p);
12+
}
13+
14+
for (var i = 0; i < G.length; i++) { // start from every node
15+
tracer.print('start from ' + i);
16+
D = new Array(G.length);
17+
DFS(i);
18+
tracer.clear();
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var tracer = new GraphTracer();
2+
var G = [
3+
[3, 4], // connected nodes from node 0
4+
[2, 4],
5+
[1],
6+
[1],
7+
[2]
8+
];
9+
tracer.setData(G);
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var D; // D[i] indicates whether the i-th node is discovered or not
2+
3+
function DFS(v, p) { // v = current node, p = previous node
4+
tracer.visit(v, p);
5+
D[v] = true; // label v as discovered
6+
G[v].forEach(function (w) { // G[v] contains edges starting from v
7+
if (!D[w]) { // if w is not labeled as discovered
8+
DFS(w, v); // recursively call DFS
9+
}
10+
});
11+
D[v] = false; // label v as undiscovered
12+
tracer.leave(v, p);
13+
}
14+
15+
for (var i = 0; i < G.length; i++) { // start from every node
16+
tracer.print('start from ' + i);
17+
D = new Array(G.length);
18+
DFS(i);
19+
tracer.clear();
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var tracer = new GraphTracer();
2+
var G = [
3+
[1,2,3,4], // connected nodes from node 0
4+
[0,2,3,4],
5+
[0,1,3,4],
6+
[0,1,2,4],
7+
[0,1,2,3]
8+
];
9+
tracer.setData(G);

css/font-awesome.min.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/stylesheet.css

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
html, body {
2+
margin: 0;
3+
padding: 0;
4+
overflow: hidden;
5+
}
6+
7+
body {
8+
background: rgb(60, 63, 65);
9+
font-family: 'Roboto', sans-serif;
10+
color: rgb(187, 187, 187);
11+
}
12+
13+
a {
14+
text-decoration: none;
15+
}
16+
17+
* {
18+
-webkit-touch-callout: none;
19+
-webkit-user-select: none;
20+
-moz-user-select: none;
21+
-ms-user-select: none;
22+
-o-user-select: none;
23+
user-select: none;
24+
color: inherit;
25+
}
26+
27+
button {
28+
border: none;
29+
height: 100%;
30+
padding: 0 12px;
31+
margin: 0;
32+
background: none;
33+
font-size: 12px;
34+
outline: none;
35+
}
36+
37+
button:hover {
38+
background: rgba(0, 0, 0, .15);
39+
}
40+
41+
button.active {
42+
background: rgb(44, 44, 44);
43+
}
44+
45+
button.indent {
46+
padding-left: 24px;
47+
}
48+
49+
.divider {
50+
position: absolute !important;
51+
z-index: 3;
52+
}
53+
54+
.divider.vertical {
55+
cursor: ew-resize;
56+
}
57+
58+
.divider.horizontal {
59+
cursor: ns-resize;
60+
}
61+
62+
nav {
63+
height: 30px;
64+
width: 100%;
65+
padding: 0 16px;
66+
}
67+
68+
nav h3 {
69+
display: inline;
70+
}
71+
72+
.nav-arrow {
73+
padding: 0 4px;
74+
}
75+
76+
.buttons {
77+
float: right;
78+
height: 100%;
79+
}
80+
81+
.sidemenu {
82+
top: 30px;
83+
bottom: 0;
84+
left: 0;
85+
right: 85%;
86+
visibility: hidden;
87+
}
88+
89+
.sidemenu.active {
90+
visibility: visible;
91+
}
92+
93+
#list > button {
94+
display: block;
95+
width: 100%;
96+
height: 30px;
97+
text-align: left;
98+
}
99+
100+
.workspace {
101+
position: absolute;
102+
top: 30px;
103+
bottom: 0;
104+
left: 15%;
105+
right: 0;
106+
}
107+
108+
nav,
109+
section {
110+
position: absolute;
111+
border: 1px solid rgb(44, 44, 44);
112+
box-sizing: border-box;
113+
}
114+
115+
.viewer_container,
116+
.editor_container {
117+
position: absolute;
118+
}
119+
120+
.viewer_container {
121+
top: 0;
122+
bottom: 0;
123+
left: 0;
124+
right: 50%;
125+
}
126+
127+
.editor_container {
128+
top: 0;
129+
bottom: 0;
130+
left: 50%;
131+
right: 0;
132+
}
133+
134+
.visualize_container {
135+
top: 0;
136+
bottom: 50%;
137+
left: 0;
138+
right: 0;
139+
}
140+
141+
.tab_container {
142+
top: 50%;
143+
bottom: 30px;
144+
left: 0;
145+
right: 0;
146+
}
147+
148+
.tab {
149+
position: absolute;
150+
width: 100%;
151+
height: 100%;
152+
overflow: scroll;
153+
visibility: hidden;
154+
}
155+
156+
.tab > .wrapper {
157+
padding: 16px;
158+
box-sizing: border-box;
159+
}
160+
161+
.tab.active {
162+
visibility: visible;
163+
}
164+
165+
.tab_bar {
166+
bottom: 0;
167+
left: 0;
168+
right: 0;
169+
height: 30px;
170+
}
171+
172+
.files_bar {
173+
left: 0;
174+
right: 0;
175+
height: 30px;
176+
}
177+
178+
.explanation_container {
179+
top: 30px;
180+
left: 0;
181+
right: 0;
182+
height: 30px;
183+
background: rgb(44, 44, 44);
184+
padding: 0 8px;
185+
line-height: 30px;
186+
font-size: 12px;
187+
}
188+
189+
.data_container {
190+
top: 60px;
191+
bottom: 70%;
192+
left: 0;
193+
right: 0;
194+
}
195+
196+
.code_container {
197+
left: 0;
198+
top: 30%;
199+
right: 0;
200+
bottom: 0;
201+
}
202+
203+
pre {
204+
box-sizing: border-box;
205+
height: 100%;
206+
width: 100%;
207+
margin: 0;
208+
padding: 0;
209+
border: 1px solid rgb(81, 81, 81);
210+
background: rgb(43, 43, 43);
211+
outline: none;
212+
resize: none;
213+
}
214+
215+
.toast_container {
216+
position: absolute;
217+
bottom: 0;
218+
right: 0;
219+
padding: 12px;
220+
z-index: 2;
221+
}
222+
223+
.toast {
224+
width: 280px;
225+
border: 1px solid;
226+
border-radius: 4px;
227+
padding: 16px;
228+
margin: 16px;
229+
}
230+
231+
.toast.error {
232+
border-color: rgb(150, 0, 0);
233+
background: rgba(120, 0, 0, .8);
234+
}

fonts/FontAwesome.otf

122 KB
Binary file not shown.

fonts/fontawesome-webfont.eot

74.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)