-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
278 lines (271 loc) · 15.4 KB
/
index.html
File metadata and controls
278 lines (271 loc) · 15.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
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
<html>
<head>
<title>Rubber band method</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" type="image/png" href="favicon.ico">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<!-- Icons from https://remixicon.com/ -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/14.7.0/math.js" integrity="sha512-K6Imlt5xrxgmId3tt62Mlz0Glk7QWzDT3f64XdK7uq+JggHJtldgpC5jO9E6jgJepcx0W4GiADcvAwkPqn6KNg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<div class="grid-container" style="display:grid">
<div id="header" style="grid-area: header">
<h1>The rubber band method</h1>
</div>
<div id="graph-menu" style="grid-area: graph-menu">
<div class="graph-menu-row-1 graph-menu-row">
<button id="run-button"><img class="menu-icon" src="assets/play-line.svg"> Run </button>
<button id="randomize-button"><img class="menu-icon" src="assets/shuffle-line.svg"> Randomize </button>
<div class="dropdown">
<button class="dropbtn"><img class="menu-icon" src="assets/share-line.svg"> Load graph </button>
<div class="dropdown-content" id="loadGraphDropdown">
</div>
</div>
<div class="dropdown" style="display:inline-block;">
<button class="dropbtn" id="random-graph-button"><img class="menu-icon" src="assets/shuffle-line.svg"> Random graph </button>
<div class="dropdown-content" id="randomGraphDropdown">
<div><span for="random-node-count">Nodes:</span>
<input type="number" id="random-node-count" min="2" max="100" value="10" style="width:4em;">
</div>
<div><span for="random-edge-prob">Edge probability:</span>
<input type="number" id="random-edge-prob" min="0" max="1" step="0.01" value="0.2" style="width:4em;">
</div>
<div><button id="generate-random-graph">Generate</button></div>
</div>
</div>
<button id="edit-graph-button"><img id="edit-graph-icon" class="menu-icon" src="assets/lock-line.svg"> Edit graph </button>
</div>
<div id="edit-buttons-container" class="graph-menu-row-2 graph-menu-row" hidden="true">
<button id="add-edge-button"> Add edge </button>
<button id="manual-move-button"> Manual move </button>
<button id="rubber-band-move-button"> Rubber move </button>
</div>
<div id="SquareTiling-controls" class="graph-menu-row-2 graph-menu-row" hidden="true">
<button id="squares-button"> Squares </button>
<button id="show-hide-button"> Show / hide </button>
<button id="morph-button"> Morph </button>
</div>
<div id="MaxCut-controls" class="graph-menu-row-2 graph-menu-row" hidden="true">
<button id="max-cut-button"> Max cut </button>
<button id="random-cut-button"> Random cut </button>
<div class="dropdown">
<button class="dropbtn"><img class="menu-icon" src="assets/contract-left-right-line.svg"> Force </button>
<div class="dropdown-content" id="forceDropdown">
<label><input type="radio" name="force-rb" data-force="attract" checked="checked" />attract</label><br>
<label><input type="radio" name="force-rb" data-force="repel" />repel</label><br>
<label><input type="radio" name="force-rb" data-force="repel-constrained" />repel constrained</label>
</div>
</div>
</div>
</div>
<div id="graph-container" style="grid-area: graph;"></div>
<div id="topic-menu" style="grid-area: topic-menu">
<div class="tabs" id="topicTabs">
<button class="tablink" data-topic-name="Intro" id="IntroTab">Intro</button>
<button class="tablink" data-topic-name="Planarity">Planarity</button>
<button class="tablink" data-topic-name="Connectivity">Connectivity</button>
<button class="tablink" data-topic-name="MaxCut">Max cut</button>
<button class="tablink" data-topic-name="SquareTiling">Square tiling</button>
</div>
</div>
<div id="topic-container" style="grid-area:topic; overflow-y:scroll">
<div id="topic-text"></div>
<br>
</div>
<div id="info" style="grid-area: info">
Graph: <span id="graph-name" style="display:inline-block;width:10em"> </span>
Vertices: <span id="num-vertices" style="display:inline-block;width:3em"> </span>
Edges: <span id="num-edges" style="display:inline-block;width:3em"> </span>
<span id="max-cut-info" style="display:none">
Current cut size: <span id="current-cut-size" style="display:inline-block;width:3em"> </span>
Max cut size: <span id="max-cut-size" style="display:inline-block;width:3em">?</span>
</span>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js@3.0/dist/svg.min.js"></script>
<script type="module" src="main.js"></script>
<script type="module" src="tooltips.js"></script>
<div id="context-menus">
<div id="svg-context-menu" class="context-menu" style="display:none;">
<div><button class="context-menu-item" id="svg-add-node-button"><img class="menu-icon" src="assets/add-circle-line.svg"> Add node </button></div>
<div><button class="context-menu-item" id="unnail-all-button"><img class="menu-icon" src="assets/unpin-line.svg"> Unnail all nodes </button></div>
</div>
<div id="node-context-menu" class="context-menu" style="display:none;">
<div><button class="context-menu-item" id="delete-node-button"><img class="menu-icon" src="assets/delete-bin-line.svg"> Delete node </button></div>
<div><span class="context-menu-item" style="font-size:1.1em;margin:0.2em;">
Constraint:
<select id="node-constraint-dropdown" style="padding:0.2em;margin:0.2em;">
<option value="unnailed">Unnailed</option>
<option value="nailed">Nailed</option>
<option value="fixed_x">Fixed X</option>
<option value="fixed_y">Fixed Y</option>
</select>
</span></div>
<div><span class="context-menu-item" style="font-size:1.1em;margin:0.2em;" htmlFor="node-color-dropdown">
Change color:
<select id="node-color-dropdown" style="padding:0.2em;margin:0.2em;">
</select>
</span></div>
</div>
<div id="edge-context-menu" class="context-menu" style="display:none;">
<div><button class="context-menu-item" id="delete-edge-button"><img class="menu-icon" src="assets/delete-bin-line.svg"> Delete edge </button></div>
<div><button class="context-menu-item" id="split-node-button"><img class="menu-icon" src="assets/add-circle-line.svg"> Add split node </button></div>
<div><span style="margin-left: 0.3em;font-size: 1.1em;">Set strength: </span>
<input type="range"
id="edge-strength-slider"
class="context-menu-item"
min="0.25"
max="6"
value="1"
step="0.25"
style="width:8em; vertical-align: middle; margin-left:0.5em;">
<span id="edge-strength-value" class="context-menu-item" style="display:inline-block; width:2.5em;">1</span></div>
</div>
</div>
<div id="tooltip-box" class="tooltip-box"></div>
<div id="tooltip-contents" style="display:none;">
<div id="tooltip-Tutte">
<img src="assets/W._T._Tutte.jpg" alt="William Thomas Tutte" style="height:180px;"><br>
<b>William Thomas Tutte</b> (1917-2002): British-Canadian mathematician, who made fundamental
contributions to graph theory. For more, see
<a href="https://uwaterloo.ca/combinatorics-and-optimization/professor-william-t-tutte" target="_blank">https://uwaterloo.ca/combinatorics-and-optimization/professor-william-t-tutte</a>.
</div>
<div id="tooltip-Tutte-paper">
W.T. Tutte: How to draw a graph, <i>Proc. London Math. Soc.</i> <b>13</b> (1963), 743-768.
</div>
<div id="tooltip-LLW-paper">
N. Linial, L. Lovász & A. Wigderson: Rubber bands, convex embeddings and graph connectivity, <i>Combinatorica</i>, Vol. 8, 91-102, (1988)
</div>
<div id="tooltip-GW-paper">
M.X. Goemans and D.P.Williamson: <i>.879-approximation algorithms for MAX CUT and MAX 2SAT</i>, Proc. 26th ACM Symp. on Theory of Computing (1994), 422-431.
<br><a href="https://dl.acm.org/doi/10.1145/195058.195216" target="_blank">https://dl.acm.org/doi/10.1145/195058.195216</a>
</div>
<div id="tooltip-BSST-paper">
R.L. Brooks, C. A. B. Smith, A. H. Stone, W. T. Tutte: The dissection of rectangles into squares, <i>Duke Math. J.</i> 7 (1940), 312-340.
</div>
<div id="tooltip-Duijvestijn-note">
A.J.W. Duijvestijn: <a href="https://doi.org/10.1016%2F0095-8956%2878%2990041-2" target="_blank">Simple perfect squared square of lowest order</a>, <i>Journal of Combinatorial Theory, Series B</i> 25 (1978), 240-243.
<!-- <br><a href="https://doi.org/10.1016%2F0095-8956%2878%2990041-2" target="_blank">https://doi.org/10.1016%2F0095-8956%2878%2990041-2</a> -->
</div>
<div id="tooltip-Duijvestijn-thesis">
A.J.W. Duijvestijn: <a href="https://pure.tue.nl/ws/portalfiles/portal/1854405/44157.pdf" target="_blank">Electronic Computation of Squared Rectangles</a>, PhD thesis, Technische Hogeschool Eindhoven, 1962.
<!-- <br><a href="https://pure.tue.nl/ws/portalfiles/portal/1854405/44157.pdf" target="_blank">https://pure.tue.nl/ws/portalfiles/portal/1854405/44157.pdf</a> -->
</div>
<div id="tooltip-planar">
A graph is <b>planar</b> if it can be drawn in the plane so that the edges are continuous curves that do not intersect each other. Such a drawing is called an <b>embedding</b> of the graph in the plane.
</div>
<div id="tooltip-face">
A 3-connected planar graph, when drawn in the plane without edge crossings, divides the plane into regions called <b>faces</b>, which are bounded by cycles. While there are many ways to draw the graph, the family of these cycles is always the same. These cycles can be characterized by the properties that
<ul>
<li>they have no chords, and</li>
<li>deleting their nodes from the graph, it remains connected.</li>
</ul>
(Based on these, such a cycle can be easily found by depth-first search even if the graph is only given as an abstract graph.)
</div>
<div id="tooltip-dodecahedron">
The dodecahedron graph is the graph formed by the vertices and edges of the dodecahedron,
one of the five platonic solids.<br>
<img src="assets/dodecahedron.png" alt="Dodecahedron" style="height:180px;">
</div>
<div id="tooltip-connectivity">
A graph is <b>connected</b> if any two of its nodes can be reached from each other on a path.
<br>A graph is <b><i>k</i>-connected</b> if it is connected and it stays connected if fewer than <i>k</i> of its nodes are deleted. (We assume that the graph has more than <i>k</i> nodes.)
</div>
<div id="tooltip-3-connected">
A graph is 3-connected if it is connected and it stays connected if any two of its nodes
are deleted. (We assume that the graph has at least four nodes.)
</div>
<div id="tooltip-cut">
A <b>cut</b> in a graph is obtained by dividing the nodes into two classes, and taking the edges connecting nodes in different classes.
</div>
<div id="tooltip-brute-force">
<b>Brute force</b> in this case means looking at all possible ways of dividing the nodes into
two classes, counting the edges that go across, and selecting the best.
<br>
Actually, in this program a useful trick called <b>Branch-and-Bound</b> is added:
we do not look at extensions of a partial coloring if some easy calculation tells us
that they are not going to beat the best cut found so far.
<!-- This allows us to find the maximum cut in graphs -->
<!-- with 20+ nodes. Real brute force would fail on graphs with about 15 nodes. -->
</div>
<div id="tooltip-equilibrium">
Working out the physics: the <i>energy</i> of the system is defined by: <br>
<math display="block" class="tml-display" style="display:block math;margin-top: 0.4em;margin-bottom: 0.4em;">
<mrow>
<mrow>
<munder>
<mo movablelimits="false">∑</mo>
<mrow>
<mi>i</mi><mo separator="true">,</mo><mi>j</mi><mo>∈</mo><mi>E</mi><mo form="prefix" stretchy="false">(</mo><mi>G</mi><mo form="postfix" stretchy="false" lspace="0em" rspace="0em">)</mo>
</mrow>
</munder>
</mrow>
<mo form="prefix" stretchy="false">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo>-</mo><msub><mi>x</mi><mi>j</mi></msub><msup><mo form="postfix" stretchy="false">)</mo><mn>2</mn></msup>
<mo>+</mo>
<mo form="prefix" stretchy="false">(</mo>
<msub><mi>y</mi><mi>i</mi></msub>
<mo>-</mo>
<msub><mi>y</mi><mi>j</mi></msub>
<msup><mo form="postfix" stretchy="false">)</mo><mn>2</mn></msup>
<mo separator="true">,</mo>
</mrow>
</math>
where <math>
<mrow>
<mo form="prefix" stretchy="false">(</mo>
<msub><mi>x</mi><mi>i</mi></msub>
<mo separator="true">,</mo>
<msub><mi>y</mi><mi>i</mi></msub>
<mo form="postfix" stretchy="false">)</mo>
</mrow>
</math> is the position of node <math><mi>i</mi></math> in the plane. Taking gradients it is easy to derive the <b>equilibrium condition</b>: every node that is not nailed down must be at the <i>center of gravity</i> of its neighbors. In formula:
<math display="block" class="tml-display" style="display:block math;margin-top: 0.4em;margin-bottom: 0.4em;">
<mrow>
<mfrac>
<mn>1</mn>
<mrow>
<mi>deg</mi><mo form="prefix" stretchy="false">(</mo><mi>i</mi><mo form="postfix" stretchy="false" lspace="0em" rspace="0em">)</mo>
</mrow>
</mfrac>
<mrow>
<munder>
<mo movablelimits="false">∑</mo>
<mrow>
<mi>j</mi><mo>∈</mo><mi>N</mi><mo form="prefix" stretchy="false">(</mo><mi>i</mi><mo form="postfix" stretchy="false" lspace="0em" rspace="0em">)</mo>
</mrow>
</munder>
</mrow>
<msub><mi>x</mi><mi>j</mi></msub>
<mo>=</mo>
<msub><mi>x</mi><mi>i</mi></msub>
</mrow>
</math> and <math display="block" class="tml-display" style="display:block math;">
<mrow>
<mfrac>
<mn>1</mn>
<mrow>
<mi>deg</mi><mo form="prefix" stretchy="false">(</mo><mi>i</mi><mo form="postfix" stretchy="false" lspace="0em" rspace="0em">)</mo>
</mrow>
</mfrac>
<mrow>
<munder>
<mo movablelimits="false">∑</mo>
<mrow>
<mi>j</mi><mo>∈</mo><mi>N</mi><mo form="prefix" stretchy="false">(</mo><mi>i</mi><mo form="postfix" stretchy="false" lspace="0em" rspace="0em">)</mo>
</mrow>
</munder>
</mrow>
<msub><mi>y</mi><mi>j</mi></msub>
<mo>=</mo>
<msub><mi>y</mi><mi>i</mi></msub>
</mrow>
</math>
</div>
</div>
</body>
</html>