Skip to content

Commit 0f126a3

Browse files
committed
fix: deserialize graph referencing the wrong node
1 parent 5e35bb2 commit 0f126a3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/utils/deserializeGraph.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Graph } from '../Graph.js';
2-
import { SerializedInput } from '../types.js';
2+
import { NoInfer, SerializedInput } from '../types.js';
33

44
export function deserializeGraph<Node, LinkProps, NodeIdentity>(
55
...args: Node extends object
6-
? [data: SerializedInput<Node, LinkProps>, identityFn: (node: Node) => NodeIdentity]
6+
? [
7+
data: SerializedInput<Node, LinkProps>,
8+
identityFn: (node: NoInfer<Node>) => NodeIdentity,
9+
]
710
: [data: SerializedInput<Node, LinkProps>]
811
): Graph<Node, LinkProps> {
912
const [data, identityFn] = args;
@@ -27,7 +30,7 @@ export function deserializeGraph<Node, LinkProps, NodeIdentity>(
2730
}
2831

2932
const source = nodeIdentityMap.get(identityFn(link.source)) ?? link.source;
30-
const target = nodeIdentityMap.get(identityFn(link.source)) ?? link.target;
33+
const target = nodeIdentityMap.get(identityFn(link.target)) ?? link.target;
3134

3235
g.addEdge.apply(g, [source, target, link.weight, link.props] as never);
3336
});

0 commit comments

Comments
 (0)