Skip to content

Commit

Permalink
fix(Vis View): 🐛 Force Directed Graph: Path finding wasn't working co…
Browse files Browse the repository at this point in the history
…rrectly, oops
  • Loading branch information
SkepticMystic committed Aug 15, 2021
1 parent da8e90a commit 4d6a6f0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Visualisations/ForceDirectedG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,21 @@ export const forceDirectedG = (
paths: { [node: string]: graphlib.Path },
startNode: string
) {
if (
startNode === currFile.basename ||
paths[startNode].distance === Infinity
)
const currFileName = currFile.basename;
if (startNode === currFileName || paths[startNode].distance === Infinity)
return [];
let step = startNode;

const path: string[] = [startNode];
let i = 0;
while (paths[step].distance > 1 && i < 200) {
const MAX = 300;
while (paths[step].predecessor !== currFileName && i < MAX) {
i++;
step = paths[startNode].predecessor;
step = paths[step].predecessor;
path.push(step);
}
if (i >= 200) return [];
path.push(currFile.basename);
if (i >= MAX) return [];
path.push(currFileName);
return path;
}

Expand Down

0 comments on commit 4d6a6f0

Please sign in to comment.