Skip to content

Commit

Permalink
fix(Vis View): 🐛 Force Directed Graph: Current note doesn't have to h…
Browse files Browse the repository at this point in the history
…ave breadcrumbs for fdg to show

If a note doesn't have breadcrumbs, it isn't added to any of the graphs as a node. Fixes #93
  • Loading branch information
SkepticMystic committed Aug 21, 2021
1 parent 6c9a57a commit fc66973
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Visualisations/ForceDirectedG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const forceDirectedG = (
) => {
const { settings } = modal.plugin;
let nodeToGetTo = currFile.basename;
console.log({ nodeToGetTo });

console.time("Find all paths");
let pathsFromNodeToGetTo = graphlib.alg.dijkstra(graph, nodeToGetTo);
Expand Down Expand Up @@ -50,10 +51,17 @@ export const forceDirectedG = (
target: { index: number; x: number; y: number };
}[] = data.links.map((d) => Object.create(d));

const currNode = data.nodes.find((node) => node.name === currFile.basename);
let currNodeIndex: number;
if (!currNode) {
const id = data.nodes.length;
data.nodes.push({ id, name: currFile.basename });
currNodeIndex = id;
} else {
currNodeIndex = currNode.id;
}

const nodes = data.nodes.map((d) => Object.create(d));
const currNodeIndex = data.nodes.find(
(node) => node.name === currFile.basename
).id;

const simulation = d3
.forceSimulation(nodes)
Expand Down

0 comments on commit fc66973

Please sign in to comment.