Skip to content

Commit

Permalink
added check for existing node (#550)
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored Apr 20, 2023
1 parent 0568c70 commit c8f2b08
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions public/pages/Correlations/containers/CorrelationsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class Correlations extends React.Component<CorrelationsProps, Correlation
return this.shouldShowFinding(corr.finding1) && this.shouldShowFinding(corr.finding2);
});
const createdEdges = new Set<string>();
const createdNodes = new Set<string>();
const graphData: CorrelationGraphData = {
graph: {
nodes: [],
Expand All @@ -175,8 +176,14 @@ export class Correlations extends React.Component<CorrelationsProps, Correlation
return;
}

this.addNode(graphData.graph.nodes, correlation.finding1);
this.addNode(graphData.graph.nodes, correlation.finding2);
if (!createdNodes.has(correlation.finding1.id)) {
this.addNode(graphData.graph.nodes, correlation.finding1);
createdNodes.add(correlation.finding1.id);
}
if (!createdNodes.has(correlation.finding2.id)) {
this.addNode(graphData.graph.nodes, correlation.finding2);
createdNodes.add(correlation.finding2.id);
}
this.addEdge(graphData.graph.edges, correlation.finding1, correlation.finding2);

createdEdges.add(`${correlation.finding1.id}:${correlation.finding2.id}`);
Expand Down

0 comments on commit c8f2b08

Please sign in to comment.