Skip to content

Commit

Permalink
Merge pull request #41 from tone-row/multiple-edges-between-nodes
Browse files Browse the repository at this point in the history
Show multiple edges between nodes
  • Loading branch information
rob-gordon committed Mar 4, 2021
2 parents a0fc562 + 62678fa commit 7d86c21
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/App.tsx
Expand Up @@ -363,9 +363,17 @@ function parseText(text: string) {
if (parent) {
const source = getNodeId(lines[checkLine - 1], checkLine);
const target = linkMatch ? linkMatch : getNodeId(line, lineNumber);

// Find a unique id
let id = `${source}_${target}:0`;
while (elements.map(({ data: { id } }) => id).includes(id)) {
let [, count] = id.split(":");
count = (parseInt(count, 10) + 1).toString();
id = `${source}_${target}:${count}`;
}
elements.push({
data: {
id: [source, target].join("_"),
id,
source,
target,
label: getEdgeLabel(line),
Expand Down

0 comments on commit 7d86c21

Please sign in to comment.