Merge branch 'hotfix/cjc' into 'main'

修改二叉树回指的bug

See merge request phenomLi/StructV2!14
This commit is contained in:
chen jiancheng 2022-03-11 09:08:25 +00:00
commit 76ee9b1968
2 changed files with 168 additions and 195 deletions

View File

@ -5,7 +5,7 @@ SV.registerLayout('BinaryTree', {
default: { default: {
type: 'binary-tree-node', type: 'binary-tree-node',
size: [60, 30], size: [60, 30],
label: '[id]', label: '[data]',
style: { style: {
fill: '#b83b5e', fill: '#b83b5e',
stroke: '#333', stroke: '#333',
@ -77,6 +77,8 @@ SV.registerLayout('BinaryTree', {
return null; return null;
} }
node.visited = true;
if (node.child && node.child[0]) { if (node.child && node.child[0]) {
leftGroup = this.layoutItem(node.child[0], layoutOptions); leftGroup = this.layoutItem(node.child[0], layoutOptions);
} }
@ -90,10 +92,10 @@ SV.registerLayout('BinaryTree', {
node.set('y', leftBound.y - layoutOptions.yInterval - height); node.set('y', leftBound.y - layoutOptions.yInterval - height);
} }
if(rightGroup) { if (rightGroup) {
rightBound = rightGroup.getBound(); rightBound = rightGroup.getBound();
if(leftGroup) { if (leftGroup) {
rightGroup.translate(0, leftBound.y - rightBound.y) rightGroup.translate(0, leftBound.y - rightBound.y)
} }
@ -115,12 +117,11 @@ SV.registerLayout('BinaryTree', {
node.set('x', leftBound.x + leftBound.width + layoutOptions.xInterval / 2 - width); node.set('x', leftBound.x + leftBound.width + layoutOptions.xInterval / 2 - width);
} }
if(rightGroup) { if (rightGroup) {
rightBound = rightGroup.getBound(); rightBound = rightGroup.getBound();
node.set('x', rightBound.x - layoutOptions.xInterval / 2 - width); node.set('x', rightBound.x - layoutOptions.xInterval / 2 - width);
} }
node.visited = true;
if (leftGroup) { if (leftGroup) {
group.add(leftGroup); group.add(leftGroup);
@ -144,13 +145,11 @@ SV.registerLayout('BinaryTree', {
}, },
}); });
[ [{
{
id: 6385328, id: 6385328,
data: '', data: '',
external: ['L'], external: ['L'],
root: true, root: true,
after: null, after: null,
next: null, next: null,
}, }, ];
];

View File

@ -1,103 +1,77 @@
const SOURCES_DATA = [{ const SOURCES_DATA = [{
"LinkList0": { "BinaryTree0": {
"data": [{ "data": [{
"id": "0x616eb0", "external": [
"data": "Z", "T1"
"next": "0x616ef0",
"loopNext": null,
"rootExternal": [
"L"
], ],
"child": [
"0x617ee0",
"0x617f10"
],
"id": "0x617eb0",
"name": "T1",
"data": "Z",
"root": true,
"type": "default" "type": "default"
}, },
{ {
"freed": true, "child": [
"id": "0x616ef0", "0x0",
"data": "", "0x0"
"next": "0x605010", ],
"loopNext": null, "id": "0x617ee0",
"name": "T1->lchild",
"data": "D",
"type": "default" "type": "default"
}, },
{ {
"id": "0x605010", "child": [
"data": "1", "0x617f70",
"external": [ "0x617f40"
"t"
], ],
"next": null, "id": "0x617f10",
"loopNext": null, "name": "T1->rchild",
"data": "C",
"type": "default" "type": "default"
}
],
"layouter": "LinkList"
},
"handleUpdate": {
"isEnterFunction": false,
"isFirstDebug": false
}
}, {
"LinkList0": {
"data": [{
"id": "0x616eb0",
"data": "Z",
"external": [
"L"
],
"next": "0x616ef0",
"loopNext": null
}, },
{ {
"freed": true, "child": [
"id": "0x616ef0", "0x0",
"data": "", "0x0"
"next": "0x605010", ],
"loopNext": null "id": "0x617f70",
"name": "(T1->rchild)->lchild",
"data": "A",
"type": "default"
}, },
{ {
"id": "0x605010", "child": [
"data": "1", "0x0",
"0x617fa0"
],
"id": "0x617f40",
"name": "(T1->rchild)->rchild",
"data": "B",
"type": "default",
"external": [ "external": [
"t" "t"
], ]
"next": null,
"loopNext": null
}
],
"layouter": "LinkList"
},
"handleUpdate": {
"isEnterFunction": false,
"isFirstDebug": false
}
}, {
"LinkList0": {
"data": [{
"id": "0x616eb0",
"data": "Z",
"external": [
"L"
],
"next": "0x616ef0",
"loopNext": null
}, },
{ {
"freed": true, "child": [
"id": "0x616ef0", "0x0",
"data": "", "0x617f40"
"next": "0x605010",
"loopNext": null
},
{
"id": "0x605010",
"data": "1",
"external": [
"t"
], ],
"next": null, "id": "0x617fa0",
"loopNext": null "name": "((T1->rchild)->rchild)->rchild",
"data": "E",
"type": "default",
"external": [
"r"
]
} }
], ],
"layouter": "LinkList" "layouter": "BinaryTree"
}, },
"handleUpdate": { "handleUpdate": {
"isEnterFunction": false, "isEnterFunction": false,