jkstra
Version:
Small JavaScript graph routing library
35 lines (33 loc) • 1.48 kB
HTML
<html>
<head>
<meta charset="utf-8" />
<title>jkstra demo</title>
<link rel="stylesheet" href="style.css">
<script src="main.js"></script>
<script src="../build/jkstra.js"></script>
</head>
<body>
<h1>jkstra demo</h1>
<div id="explanation">
<p>This demonstrates the path finding calpabilities of the <b><a href="https://github.com/bbecquet/jkstra">jkstra</a></b> library.
<i>jkstra</i> stores graphs internally as adjacency lists, not matrices, but for a demo it's easier to picture it like that.</p>
<p>Here each cell is a node (vertex) in the graph. It's related to its adjacent vertices by edges with travel cost = 1
(for horizontally and vertically adjacent nodes), or √2 (for diagonally adjacent nodes). Black cells are obstacles.</p>
</div>
<p><b>Left-click to set the starting point. Right-click for the end point.</b></p>
<div id="controls">
<div>
<p><label><input type="checkbox" id="useHeuristic" />Use A* (with distance heuristic)</label></p>
<p><label><input type="checkbox" id="bidirectional" />Bidirectional</label></p>
<button id="computePath">Compute shortest path</button>
</div>
<div id="result">
<p>Path cost: <span id="pathCost"></span></p>
<p>Settled nodes: <span id="settledNodes"></span></p>
</div>
</div>
</div>
<table><tbody id="grid"></tbody></table>
</body>
</html>