Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
Signed-off-by: rashidakanchwala <rashida_kanchwala@mckinsey.com>
  • Loading branch information
rashidakanchwala committed Nov 12, 2024
1 parent c2bd671 commit c7e08e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils/graph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import { graph } from './graph';
* which don't affect layout.
*/
export const graphNew = ({ nodes, edges, layers }) => {
/*
Sort edges to ensure consistent ordering and eliminate randomness in
graph calculations for each render
*/
const sortedEdges = edges.sort((a, b) => a.id.localeCompare(b.id));

console.log(nodes, sortedEdges, layers);

for (const node of nodes) {
node.iconSize = node.iconSize || 24;
node.icon = node.icon || 'node';
Expand All @@ -25,7 +33,7 @@ export const graphNew = ({ nodes, edges, layers }) => {
node.iconOffset = node.iconOffset || -innerWidth / 2;
}

const result = graph(nodes, edges, layers);
const result = graph(nodes, sortedEdges, layers);

return {
...result,
Expand Down

0 comments on commit c7e08e8

Please sign in to comment.