1
0
Fork 0

fixed betweeness and bug in floyd warshall

This commit is contained in:
scottashton 2014-09-04 15:22:29 +02:00
parent 2eb42db0d7
commit ff8791f6fb
1 changed files with 38 additions and 23 deletions

View File

@ -5243,15 +5243,29 @@ function CALCULATE_SHORTEST_PATHES_WITH_FLOYD_WARSHALL (graphData, options) {
});
});
});
}
}
});
});
});
var transformPath = function (paths) {
paths.forEach(function (p) {
var vTmp = [];
p.vertices.forEach(function (v) {
if (graph.fromVerticesIDs[v]) {
vTmp.push(graph.fromVerticesIDs[v]);
} else {
delete paths[i][j].paths;
}
vTmp.push(graph.toVerticesIDs[v]);
}
});
p.vertices = vTmp;
});
return paths;
};
});
});
});
Object.keys(paths).forEach(function (from) {
if (!graph.fromVerticesIDs[from]) {
return;
@ -5272,7 +5286,7 @@ function CALCULATE_SHORTEST_PATHES_WITH_FLOYD_WARSHALL (graphData, options) {
result.push({
startVertex : from,
vertex : graph.toVerticesIDs[to],
paths : options.noPaths ? null : paths[from][to].paths,
paths : options.noPaths ? null : transformPath(paths[from][to].paths),
distance : paths[from][to].distance
});
});
@ -5392,7 +5406,8 @@ function IS_EXAMPLE_SET (example) {
return (
example && (
(Array.isArray(example) && example.length > 0) ||
(typeof example === "object" && Object.keys(example) > 0)
(typeof example === "object" && Object.keys(example) > 0) ||
typeof example === "string"
)
);
@ -6902,13 +6917,13 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) {
}
d.paths.forEach(function (p) {
p.vertices.forEach(function (v) {
if (v === d.startVertex || v === d.vertex._id) {
if (v._id === d.startVertex || v._id === d.vertex._id) {
return;
}
if (!tmp[v]) {
tmp[v] = 1;
if (!tmp[v._id]) {
tmp[v._id] = 1;
} else {
tmp[v]++;
tmp[v._id]++;
}
});
});