-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
62 lines (49 loc) · 1.8 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
<!DOCTYPE HTML>
<head>
<meta charset="utf-8">
<title>Dijkstra's Shortest Path Calculator</title>
</head>
<body>
<h1>Dijkstra's Shortest Path Calculator</h1>
<h2>An interactive exploration of the famous Dijkstra algorithm</h2>
<div class="spgraph" id="graph"></div>
<p>
Number of nodes : <input type="text" id="numberOfNodes" style="width: 30px;" name="sp-nodes" value="5"/>
<input type="submit" value=" make table "
onclick="ShortestPathUtils.makeTable(document.getElementById('numberOfNodes').value);" />
</p>
<div id="distances"></div>
<div id="results"></div>
<div id="graph" class="spgraph" ></div>
<div id="distances2"></div>
<div id="results2"></div>
<div id="graph2" class="spgraph" ></div>
<link href="stylesheets/shortest-path.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascripts/d3.v3.min.js"></script>
<script type="text/javascript" src="javascripts/ShortestPathCalculator.js"></script>
<script type="text/javascript" src="javascripts/ShortestPathUtils.js"></script>
<script type="text/javascript">
var nodes = [
{ index: 0, value: 'a', r: 20 },
{ index: 1, value: 'b', r: 20 },
{ index: 2, value: 'c', r: 20 },
{ index: 3, value: 'd', r: 20 },
{ index: 4, value: 'e', r: 20 }
];
var paths = [
{ source: 0, target: 1, distance: 150 },
{ source: 0, target: 2, distance: 100 },
{ source: 2, target: 3, distance: 100 },
{ source: 2, target: 4, distance: 160 },
{ source: 1, target: 3, distance: 40 },
{ source: 3, target: 4, distance: 100 },
{ source: 1, target: 4, distance: 100 }
];
var sp1 = new ShortestPathCalculator(nodes, paths);
var route = sp1.findRoute(0,4);
var result = sp1.formatResult();
document.getElementById('results').innerHTML = result;
sp1.drawGraph('graph');
</script>
</body>
</html>