2323 for ( var j = 0 ; j < size ; j += 1 ) {
2424 if ( i === j ) {
2525 dist [ i ] [ j ] = 0 ;
26- } else if ( isNaN ( graph [ i ] [ j ] ) ) {
26+ } else if ( ! isFinite ( graph [ i ] [ j ] ) ) {
2727 dist [ i ] [ j ] = Infinity ;
2828 } else {
2929 dist [ i ] [ j ] = graph [ i ] [ j ] ;
3434 }
3535
3636 /**
37- * Floyd-Warshall algorithm. Finds the shortest path between each two vertices.<br><br>
37+ * Floyd-Warshall algorithm. Finds the shortest path between
38+ * each two vertices.<br><br>
3839 * Complexity: O(|V|^3) where V is the number of vertices.
3940 *
4041 * @public
4142 * @module graphs/shortest-path/floyd-warshall
4243 * @param {Array } graph A distance matrix of the graph.
43- * @return {Array } Array which contains the shortest distance between each two vertices.
44- *
44+ * @return {Array } Array which contains the shortest
45+ * distance between each two vertices.
46+ *
4547 * @example
46- * var floydWarshall = require('path-to-algorithms/src/graphs/shortest-path/floyd-warshall').floydWarshall;
47- * var distMatrix = [[NaN, 7, 9, NaN, NaN, 16],
48- * [7, NaN, 10, 15, NaN, NaN],
49- * [9, 10, NaN, 11, NaN, 2],
50- * [NaN, 15, 11, NaN, 6, NaN],
51- * [NaN, NaN, NaN, 6, NaN, 9],
52- * [16, NaN, 2, NaN, 9, NaN]];
48+ * var floydWarshall =
49+ * require('path-to-algorithms/src/graphs/shortest-path/floyd-warshall').floydWarshall;
50+ * var distMatrix =
51+ * [[Infinity, 7, 9, Infinity, Infinity, 16],
52+ * [7, Infinity, 10, 15, Infinity, Infinity],
53+ * [9, 10, Infinity, 11, Infinity, 2],
54+ * [Infinity, 15, 11, Infinity, 6, Infinity],
55+ * [Infinity, Infinity, Infinity, 6, Infinity, 9],
56+ * [16, Infinity, 2, Infinity, 9, Infinity]];
5357 *
5458 * // [ [ 0, 7, 9, 20, 20, 11 ],
5559 * // [ 7, 0, 10, 15, 21, 12 ],
7781
7882 exports . floydWarshall = floydWarshall ;
7983
80- } ) ( typeof window === 'undefined' ? module . exports : window ) ;
84+ } ) ( typeof window === 'undefined' ? module . exports : window ) ;
0 commit comments