Skip to content

Commit 7466c85

Browse files
committed
Add additional docs
1 parent ad963ad commit 7466c85

26 files changed

Lines changed: 1395 additions & 170 deletions

Edge.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ <h5>Parameters:</h5>
231231
</div>
232232

233233
<nav>
234-
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="searching.html">graphs/searching</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
234+
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="topological-sort.html">graphs/others/topological-sort</a></li><li><a href="bfs.html">graphs/searching/bfs</a></li><li><a href="dfs.html">graphs/searching/dfs</a></li><li><a href="bellman-ford.html">graphs/shortest-path/bellman-ford</a></li><li><a href="dijkstra.html">graphs/shortest-path/dijkstra</a></li><li><a href="floyd-warshall.html">graphs/shortest-path/floyd-warshall</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
235235
</nav>
236236

237237
<br clear="both">
238238

239239
<footer>
240-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 19:36:25 GMT+0200 (EET)
240+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 21:22:24 GMT+0200 (EET)
241241
</footer>
242242

243243
<script> prettyPrint(); </script>

Graph.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ <h4 class="name" id="prim"><span class="type-signature"></span>prim<span class="
197197
</div>
198198

199199
<nav>
200-
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="searching.html">graphs/searching</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
200+
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="topological-sort.html">graphs/others/topological-sort</a></li><li><a href="bfs.html">graphs/searching/bfs</a></li><li><a href="dfs.html">graphs/searching/dfs</a></li><li><a href="bellman-ford.html">graphs/shortest-path/bellman-ford</a></li><li><a href="dijkstra.html">graphs/shortest-path/dijkstra</a></li><li><a href="floyd-warshall.html">graphs/shortest-path/floyd-warshall</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
201201
</nav>
202202

203203
<br clear="both">
204204

205205
<footer>
206-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 19:36:25 GMT+0200 (EET)
206+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 21:22:24 GMT+0200 (EET)
207207
</footer>
208208

209209
<script> prettyPrint(); </script>

Vertex.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ <h5>Parameters:</h5>
185185
</div>
186186

187187
<nav>
188-
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="searching.html">graphs/searching</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
188+
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="topological-sort.html">graphs/others/topological-sort</a></li><li><a href="bfs.html">graphs/searching/bfs</a></li><li><a href="dfs.html">graphs/searching/dfs</a></li><li><a href="bellman-ford.html">graphs/shortest-path/bellman-ford</a></li><li><a href="dijkstra.html">graphs/shortest-path/dijkstra</a></li><li><a href="floyd-warshall.html">graphs/shortest-path/floyd-warshall</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
189189
</nav>
190190

191191
<br clear="both">
192192

193193
<footer>
194-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 19:36:25 GMT+0200 (EET)
194+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 21:22:24 GMT+0200 (EET)
195195
</footer>
196196

197197
<script> prettyPrint(); </script>

bellman-ford.html

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>JSDoc: Module: graphs/shortest-path/bellman-ford</title>
6+
7+
<script src="scripts/prettify/prettify.js"> </script>
8+
<script src="scripts/prettify/lang-css.js"> </script>
9+
<!--[if lt IE 9]>
10+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11+
<![endif]-->
12+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14+
</head>
15+
16+
<body>
17+
18+
<div id="main">
19+
20+
<h1 class="page-title">Module: graphs/shortest-path/bellman-ford</h1>
21+
22+
23+
24+
25+
26+
<section>
27+
28+
<header>
29+
<h2>
30+
graphs/shortest-path/bellman-ford
31+
</h2>
32+
33+
</header>
34+
35+
<article>
36+
<div class="container-overview">
37+
38+
39+
40+
41+
<div class="description">Bellman–Ford algorithm computes shortest paths from a single source
42+
vertex to all of the other vertices in a weighted digraph (negative weights allowed).<br><br>
43+
Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively.</div>
44+
45+
46+
47+
<dl class="details">
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
<dt class="tag-source">Source:</dt>
68+
<dd class="tag-source"><ul class="dummy"><li>
69+
<a href="bellman-ford.js.html">graphs/shortest-path/bellman-ford.js</a>, <a href="bellman-ford.js.html#line10">line 10</a>
70+
</li></ul></dd>
71+
72+
73+
74+
75+
76+
77+
78+
</dl>
79+
80+
81+
82+
<h3>Example</h3>
83+
84+
<pre class="prettyprint"><code>require('path-to-algorithms/src/graphs/shortest-path/bellman-ford');
85+
86+
var glob = (typeof window === 'undefined') ? global : window;
87+
var Edge = glob.Edge;
88+
var bellmanFord = glob.bellmanFord;
89+
var edges = [];
90+
var vertexes = [0, 1, 2, 3, 4];
91+
92+
edges.push(new Edge(0, 1, -1));
93+
edges.push(new Edge(0, 2, 4));
94+
edges.push(new Edge(1, 2, 3));
95+
edges.push(new Edge(1, 3, 2));
96+
edges.push(new Edge(3, 1, 1));
97+
edges.push(new Edge(4, 3, -3));
98+
edges.push(new Edge(1, 4, 2));
99+
edges.push(new Edge(3, 2, 5));
100+
101+
// {
102+
// parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 },
103+
// distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 }
104+
// }
105+
var pathInfo = bellmanFord(vertexes, edges, 0);</code></pre>
106+
107+
108+
109+
</div>
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
</article>
129+
130+
</section>
131+
132+
133+
134+
135+
</div>
136+
137+
<nav>
138+
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="topological-sort.html">graphs/others/topological-sort</a></li><li><a href="bfs.html">graphs/searching/bfs</a></li><li><a href="dfs.html">graphs/searching/dfs</a></li><li><a href="bellman-ford.html">graphs/shortest-path/bellman-ford</a></li><li><a href="dijkstra.html">graphs/shortest-path/dijkstra</a></li><li><a href="floyd-warshall.html">graphs/shortest-path/floyd-warshall</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
139+
</nav>
140+
141+
<br clear="both">
142+
143+
<footer>
144+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 21:22:24 GMT+0200 (EET)
145+
</footer>
146+
147+
<script> prettyPrint(); </script>
148+
<script src="scripts/linenumber.js"> </script>
149+
</body>
150+
</html>

bellman-ford.js.html

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>JSDoc: Source: graphs/shortest-path/bellman-ford.js</title>
6+
7+
<script src="scripts/prettify/prettify.js"> </script>
8+
<script src="scripts/prettify/lang-css.js"> </script>
9+
<!--[if lt IE 9]>
10+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11+
<![endif]-->
12+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14+
</head>
15+
16+
<body>
17+
18+
<div id="main">
19+
20+
<h1 class="page-title">Source: graphs/shortest-path/bellman-ford.js</h1>
21+
22+
23+
24+
25+
26+
<section>
27+
<article>
28+
<pre class="prettyprint source linenums"><code>(function (global) {
29+
'use strict';
30+
31+
function Edge(u, v, weight) {
32+
this.from = u;
33+
this.to = v;
34+
this.weight = weight;
35+
}
36+
37+
/**
38+
* Bellman–Ford algorithm computes shortest paths from a single source
39+
* vertex to all of the other vertices in a weighted digraph (negative weights allowed).&lt;br>&lt;br>
40+
* Time complexity: O(|V||E|) where V and E are the number of vertices and edges respectively.
41+
*
42+
* @public
43+
* @module graphs/shortest-path/bellman-ford
44+
* @param {Array} vertexes Vertices of the graph.
45+
* @param {Array} edges Edges of the graph.
46+
* @param {Number} source Start vertex.
47+
* @returns {Object} Object with two arrays (parents and distances) with shortest-path information.
48+
*
49+
* @example
50+
* require('path-to-algorithms/src/graphs/shortest-path/bellman-ford');
51+
*
52+
* var glob = (typeof window === 'undefined') ? global : window;
53+
* var Edge = glob.Edge;
54+
* var bellmanFord = glob.bellmanFord;
55+
* var edges = [];
56+
* var vertexes = [0, 1, 2, 3, 4];
57+
*
58+
* edges.push(new Edge(0, 1, -1));
59+
* edges.push(new Edge(0, 2, 4));
60+
* edges.push(new Edge(1, 2, 3));
61+
* edges.push(new Edge(1, 3, 2));
62+
* edges.push(new Edge(3, 1, 1));
63+
* edges.push(new Edge(4, 3, -3));
64+
* edges.push(new Edge(1, 4, 2));
65+
* edges.push(new Edge(3, 2, 5));
66+
*
67+
* // {
68+
* // parents: { '0': null, '1': 0, '2': 1, '3': 4, '4': 1 },
69+
* // distances: { '0': 0, '1': -1, '2': 2, '3': -2, '4': 1 }
70+
* // }
71+
* var pathInfo = bellmanFord(vertexes, edges, 0);
72+
*/
73+
function bellmanFord(vertexes, edges, source) {
74+
var distances = {}, parents = {}, c;
75+
for (var i = 0; i &lt; vertexes.length; i += 1) {
76+
distances[vertexes[i]] = Infinity;
77+
parents[vertexes[i]] = null;
78+
}
79+
distances[source] = 0;
80+
for (i = 0; i &lt; vertexes.length - 1; i += 1) {
81+
for (var j = 0; j &lt; edges.length; j += 1) {
82+
c = edges[j];
83+
if (distances[c.from] + c.weight &lt; distances[c.to]) {
84+
distances[c.to] = distances[c.from] + c.weight;
85+
parents[c.to] = c.from;
86+
}
87+
}
88+
}
89+
90+
for (i = 0; i &lt; edges.length; i += 1) {
91+
c = edges[i];
92+
if (distances[c.from] + c.weight &lt; distances[c.to]) {
93+
return undefined;
94+
}
95+
}
96+
97+
return { parents: parents, distances: distances };
98+
}
99+
100+
global.Edge = Edge;
101+
global.bellmanFord = bellmanFord;
102+
103+
}((typeof window === 'undefined') ? global : window));</code></pre>
104+
</article>
105+
</section>
106+
107+
108+
109+
110+
</div>
111+
112+
<nav>
113+
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="topological-sort.html">graphs/others/topological-sort</a></li><li><a href="bfs.html">graphs/searching/bfs</a></li><li><a href="dfs.html">graphs/searching/dfs</a></li><li><a href="bellman-ford.html">graphs/shortest-path/bellman-ford</a></li><li><a href="dijkstra.html">graphs/shortest-path/dijkstra</a></li><li><a href="floyd-warshall.html">graphs/shortest-path/floyd-warshall</a></li></ul><h3>Classes</h3><ul><li><a href="Edge.html">Edge</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Vertex.html">Vertex</a></li></ul>
114+
</nav>
115+
116+
<br clear="both">
117+
118+
<footer>
119+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Jan 09 2015 21:22:24 GMT+0200 (EET)
120+
</footer>
121+
122+
<script> prettyPrint(); </script>
123+
<script src="scripts/linenumber.js"> </script>
124+
</body>
125+
</html>

0 commit comments

Comments
 (0)