Skip to content

Commit

Permalink
Migrate all_pairs_distance
Browse files Browse the repository at this point in the history
  • Loading branch information
curran committed Dec 29, 2020
1 parent c2ed05a commit 0a8a8c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/all_pairs_distance.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @returns {Array} a list of distance matrices, in the order of the
* nodes in the list of connected components.
*/
reorder.all_pairs_distance = function(graph, comps) {
export function all_pairs_distance(graph, comps) {
var distances = [];
if (! comps)
comps = graph.components();
Expand All @@ -25,7 +25,7 @@ reorder.all_pairs_distance = function(graph, comps) {
* @returns {Matrix} a distance matrix, in the order of the
* nodes in the list of connected components.
*/
function all_pairs_distance_floyd_warshall(graph, comp) {
export function all_pairs_distance_floyd_warshall(graph, comp) {
var dist = reorder.infinities(comp.length, comp.length),
i, j, k, inv;
// Floyd Warshall,
Expand Down Expand Up @@ -63,8 +63,6 @@ function all_pairs_distance_floyd_warshall(graph, comp) {
return dist;
}

reorder.all_pairs_distance_floyd_warshall = all_pairs_distance_floyd_warshall;

/**
* Returns a distance matrix, computed for the specified
* connected component of a graph, and the information to compute the
Expand All @@ -76,7 +74,8 @@ reorder.all_pairs_distance_floyd_warshall = all_pairs_distance_floyd_warshall;
* reconstruct the shortest paths with the {@link
* floyd_warshall_path} function.
*/
function floyd_warshall_with_path(graph, comp) {

export function floyd_warshall_with_path(graph, comp) {
if (! comp)
comp = graph.components()[0];

Expand Down Expand Up @@ -128,8 +127,6 @@ function floyd_warshall_with_path(graph, comp) {
return [dist, next];
}

reorder.floyd_warshall_with_path = floyd_warshall_with_path;

/**
* Returns the shortest path from node u to node v, from the table
* returned by {@link floyd_warshall_with_path}.
Expand All @@ -138,7 +135,7 @@ reorder.floyd_warshall_with_path = floyd_warshall_with_path;
* @param {Integer} v - the ending node
* @return {list} a list of nodes in the shortest path from u to v
*/
function floyd_warshall_path(next, u, v) {
export function floyd_warshall_path(next, u, v) {
if (next[u][v] === undefined) return [];
var path = [u];
while (u != v) {
Expand All @@ -147,5 +144,3 @@ function floyd_warshall_path(next, u, v) {
}
return path;
}

reorder.floyd_warshall_path = floyd_warshall_path;
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export { adjacent_exchange } from './adjacent_exchange';
export { zeroes, dot, length, normalize } from './aliases';
export {
all_pairs_distance,
all_pairs_distance_floyd_warshall,
floyd_warshall_with_path,
floyd_warshall_path
} from './all_pairs_distance';

0 comments on commit 0a8a8c3

Please sign in to comment.