-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.html
More file actions
224 lines (223 loc) · 19.4 KB
/
Copy pathgraph.html
File metadata and controls
224 lines (223 loc) · 19.4 KB
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
<!doctype html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<style>
.fullscreen-container {
box-sizing: border-box;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
}
.scroll {
max-height: calc(100vh - 96px);
overflow-y: auto;
}
</style>
</head>
<body>
<div class="fullscreen-container">
<div class="container-fluid p-5 h-100">
<div class="card scroll" style="width: 20rem; position: absolute; z-index: 1;">
<div class="card-header">
<ul class="nav nav-pills" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-random-tab" data-bs-toggle="pill" data-bs-target="#pills-random" type="button" role="tab" aria-controls="pills-random" aria-selected="true" onclick="changeMode('random')">Random</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-star-tab" data-bs-toggle="pill" data-bs-target="#pills-star" type="button" role="tab" aria-controls="pills-star" aria-selected="false" onclick="changeMode('star')">Starfish</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-flower-tab" data-bs-toggle="pill" data-bs-target="#pills-flower" type="button" role="tab" aria-controls="pills-flower" aria-selected="false" onclick="changeMode('flower')">Flower</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-fractal-tab" data-bs-toggle="pill" data-bs-target="#pills-fractal" type="button" role="tab" aria-controls="pills-fractal" aria-selected="false" onclick="changeMode('fractal')">Fractal</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-mini-tab" data-bs-toggle="pill" data-bs-target="#pills-mini" type="button" role="tab" aria-controls="pills-fractal" aria-selected="false" onclick="changeMode('mini')">Mini</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-clusters-tab" data-bs-toggle="pill" data-bs-target="#pills-clusters" type="button" role="tab" aria-controls="pills-clusters" aria-selected="false" onclick="changeMode('clusters')">Clusters</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-lattice-tab" data-bs-toggle="pill" data-bs-target="#pills-lattice" type="button" role="tab" aria-controls="pills-lattice" aria-selected="false" onclick="changeMode('lattice')">Lattice</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-mobius-tab" data-bs-toggle="pill" data-bs-target="#pills-mobius" type="button" role="tab" aria-controls="pills-mobius" aria-selected="false" onclick="changeMode('mobius')">Mobius</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-edge-tab" data-bs-toggle="pill" data-bs-target="#pills-edge" type="button" role="tab" aria-controls="pills-edge" aria-selected="false" onclick="changeMode('edge')">Edge list</button>
</li>
</ul>
</div>
<div class="card-body bg-body-tertiary pb-1" >
<ul class="list-group list-group-flush">
<li class="list-group-item mb-3 bg-body-tertiary">
<div class="tab-content mb-3" id="pills-tabContent">
<div class="tab-pane show active" id="pills-random" role="tabpanel" aria-labelledby="pills-random-tab" tabindex="0">
<h6>Random graph controls</h6>
<label for="nodes">Nodes</label>
<input class="form-control" type="number" id="nodes" min="0" max="1000" value="100" step="10" oninput="inBounds(event, 0, 1000, 1)">
<label for="density" class="mt-2">Density</label>
<input class="form-control" type="number" id="density" min="0" max="1" value="0.8" step="0.001" oninput="inBounds(event, 0, 1, 0)">
<label for="maxDegree" class="mt-2">Max degree</label>
<input class="form-control" type="number" id="maxDegree" min="0" max="999" value="3" step="1" oninput="inBounds(event, 0, 999, 1)">
</div>
<div class="tab-pane" id="pills-star" role="tabpanel" aria-labelledby="pills-star-tab" tabindex="1">
<h6>Starfish graph controls</h6>
<label for="arms">Arms</label>
<input class="form-control" type="number" id="arms" min="1" max="100" value="5" step="1" oninput="inBounds(event, 1, 100, 1)">
<label for="arm_length" class="mt-2">Arm Size</label>
<input class="form-control" type="number" id="arm_length" min="0" max="100" value="20" step="1" oninput="inBounds(event, 0, 100, 1)">
</div>
<div class="tab-pane" id="pills-flower" role="tabpanel" aria-labelledby="pills-flower-tab" tabindex="2">
<h6>Flower graph controls</h6>
<label for="petals">Petals</label>
<input class="form-control" type="number" id="petals" min="1" max="50" value="6" step="1" oninput="inBounds(event, 1, 50, 1)">
<label for="petal_size" class="mt-2">Petal Size</label>
<input class="form-control" type="number" id="petal_size" min="2" max="200" value="20" step="1" oninput="inBounds(event, 2, 200, 1)">
</div>
<div class="tab-pane" id="pills-fractal" role="tabpanel" aria-labelledby="pills-fractal-tab" tabindex="3">
<h6>Fractal graph controls</h6>
<label for="degree">Degree</label>
<input class="form-control" type="number" id="degree" min="1" max="8" value="2" step="1" oninput="inBounds(event, 1, 8, 1)">
<label for="depth" class="mt-2">Depth</label>
<input class="form-control" type="number" id="depth" min="1" max="10" value="5" step="1" oninput="inBounds(event, 1, 10, 1)">
</div>
<div class="tab-pane" id="pills-mini" role="tabpanel" aria-labelledby="pills-mini-tab" tabindex="4">
<h6>Mini graph controls</h6>
<label for="mini-size">Size</label>
<input class="form-control" type="number" id="mini-size" min="1" max="10" value="6" step="1" oninput="inBounds(event, 1, 10, 1)">
<label for="mini-density" class="mt-2">Density</label>
<input class="form-control" type="number" id="mini-density" min="0" max="1" value="0.8" step="0.1" oninput="inBounds(event, 0, 1, 0)">
<label for="mini-amount" class="mt-2">Amount</label>
<input class="form-control" type="number" id="mini-amount" min="1" max="100" value="50" step="1" oninput="inBounds(event, 1, 100, 1)">
</div>
<div class="tab-pane" id="pills-clusters" role="tabpanel" aria-labelledby="pills-clusters-tab" tabindex="5">
<h6>Clusters controls</h6>
<label for="cluster-size">Cluster size</label>
<input class="form-control" type="number" id="cluster-size" min="1" max="50" value="25" step="1" oninput="inBounds(event, 1, 50, 1)">
<label for="variability" class="mt-2">Size variablity</label>
<input class="form-control" type="number" id="variability" min="0" max="1" value="0.5" step="0.01" oninput="inBounds(event, 0, 1, 0)">
<label for="cluster-amount" class="mt-2">Cluster amount</label>
<input class="form-control" type="number" id="cluster-amount" min="1" max="20" value="10" step="1" oninput="inBounds(event, 1, 20, 1)">
</div>
<div class="tab-pane" id="pills-mobius" role="tabpanel" aria-labelledby="pills-mobius-tab" tabindex="6">
<h6>Mobius controls</h6>
<label for="mobius-length">Length</label>
<input class="form-control" type="number" id="mobius-length" min="3" max="50" value="25" step="1" oninput="inBounds(event, 3, 50, 1)">
<label for="mobius-width" class="mt-2">Width</label>
<input class="form-control" type="number" id="mobius-width" min="2" max="20" value="10" step="1" oninput="inBounds(event, 2, 20, 1)">
</div>
<div class="tab-pane" id="pills-lattice" role="tabpanel" aria-labelledby="pills-lattice-tab" tabindex="7">
<h6>Lattice controls</h6>
<label for="lattice-size">Size</label>
<input class="form-control" type="number" id="lattice-size" min="1" max="30" value="10" step="1" oninput="inBounds(event, 1, 30, 1)">
<div class="form-check mt-3">
<input class="form-check-input" name="lattice-structure" type="radio" id="triangle" checked>
<label class="form-check-label" for="triangle">Triangle</label>
</div>
<div class="form-check">
<input class="form-check-input" name="lattice-structure" type="radio" id="square">
<label class="form-check-label" for="square">Square</label>
</div>
<div class="form-check">
<input class="form-check-input" name="lattice-structure" type="radio" id="hexagon">
<label class="form-check-label" for="hexagon">Hexagon</label>
</div>
</div>
<div class="tab-pane" id="pills-edge" role="tabpanel" aria-labelledby="pills-edge-tab" tabindex="8">
<h6>Edge list controls</h6>
<div class="input-group">
<textarea id="edges" class="form-control bg-body-secondary" placeholder="Enter edges in the following format:
Node 1, Node 2
Node 2, Node 3
Node 3, Node 1" style="resize: vertical; max-height: 500px;" rows="6" cols="35"></textarea>
</div>
</div>
</div>
</li>
<li class="list-group-item mb-3 bg-body-tertiary">
<div>
<button class="btn btn-primary w-100 mb-3" onclick="updateGraph()">Build graph!</button>
</div>
</li>
<li class="list-group-item mb-3 bg-body-tertiary">
<div>
<h6>Real-time controls</h6>
<label for="colorPicker">Color</label>
<input type="color" class="form-control form-control-color w-100" id="colorPicker", value="#ff0000">
<label for="sliderG" class="mt-2">Gravity</label>
<input type="range" class="form-range" id="sliderG" min="0" max="4" value="2" step="0.05">
<label for="sliderR">Repulsion</label>
<input type="range" class="form-range" id="sliderR" min="0" max="4" value="2" step="0.05">
<label for="sliderA">Attraction</label>
<input type="range" class="form-range" id="sliderA" min="0" max="10" value="5" step="0.05">
<label for="sliderF">Friction</label>
<input type="range" class="form-range" id="sliderF" min="0" max="1" value="0.15" step="0.01">
</div>
</li>
<li class="list-group-item bg-body-tertiary">
<div>
<button id="pauseButton" class="btn btn-outline-primary w-100" data-bs-toggle="button" onclick="togglePause()">Pause simulation</button>
</div>
<div class="mt-2" style="justify-content: center; text-align: center; opacity: 50%;">
<p class="mb-0"><small>Simulation must be paused to run algorithms.</small></p>
</div>
</li>
</ul>
</div>
<div class="card">
<div class="card-header">
<ul class="nav nav-pills" id="algorithms" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="dijkstra-tab" data-bs-toggle="pill" data-bs-target="#pills-dijkstra" type="button" role="tab" aria-controls="pills-dijkstra" aria-selected="true">Dijkstra's</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="kmeans-tab" data-bs-toggle="pill" data-bs-target="#pills-kmeans" type="button" role="tab" aria-controls="pills-kmeans" aria-selected="false">K-means</button>
</li>
</ul>
</div>
<div class="card-body bg-body-tertiary">
<ul class="list-group list-group-flush">
<li class="list-group-item bg-body-tertiary">
<div class="tab-content mb-2" id="pills-tabContent">
<div class="tab-pane show active" id="pills-dijkstra" role="tabpanel" aria-labelledby="pills-dijkstra-tab" tabindex="0">
<h6>Dikstra's algorithm</h6>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" role="switch" id="weights">
<label class="form-check-label" for="weights">Weighted edges</label>
</div>
<label for="dijkstra-speed" class="mt-2">Speed</label>
<input type="range" class="form-range" id="dijkstra-speed" min="0" max="3" value="1" step="0.05">
<label for="dijkstra-color">Color</label>
<input type="color" class="form-control form-control-color w-100" id="dijkstra-color", value="#ffff00">
<div>
<button id="dijkstra-button" class="btn btn-primary w-100 mt-3" onclick="dijkstras()">Go!</button>
</div>
<div id="dijkstraDone"></div>
</div>
<div class="tab-pane" id="pills-kmeans" role="tabpanel" aria-labelledby="pills-kmeans-tab" tabindex="1">
<h6>K-means algorithm</h6>
<label for="clusters">Clusters</label>
<input class="form-control" type="number" id="clusters" min="1" max="20" value="5" step="1" oninput="inBounds(event, 1, 20, 1)">
<div>
<button id="kmeans-button" class="btn btn-primary w-100 mt-3" onclick="kmeans()">Go!</button>
</div>
<div id="kmeansConverge"></div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<canvas id="graphCanvas" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;"></canvas>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
<script src="graph.js"></script>
</body>
</html>