[V4] Two edges between a node and a combo #6484
Blakko posted onGitHub
Describe the bug / 问题描述
We had a use case where after collapsing a combo we ended up with two edges between a single node and a single combo
Reproduction link / 重现链接
https://codesandbox.io/p/sandbox/frosty-firefly-7pnkm9
Steps to Reproduce the Bug or Issue / 重现步骤
Just check the codesandbox :)
G6 Version / G6 版本
4.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome
Additional context / 补充说明
Debugging the code I found out that the two edges had the following ids (pseudocode):
nodeid-comboid
comboid-nodeid
This suggests that there's something off with the logic used to compute the key.
Would it be okay to apply a sort to ensure the key's uniqueness?
I'm referring to these lines https://github.com/antvis/G6/blob/master/packages/core/src/graph/graph.ts#L2780
We could do something like
const orderedEnds = [otherEndId, comboModel.id].sort();
const vEdgeInfo = {
source: orderedEnds[0],
target: orderedEnds[1],
size,
isVEdge: true,
}
const key = orderedEnds.join('-') ;
and remove the otherEndIsSource
flag.
I could open a PR if this is approved (and I'm open to suggestions otherwise)