修改二叉树回指的bug

This commit is contained in:
cjc 2022-03-11 17:07:09 +08:00
parent 4bb64214e7
commit d06a0e15e8
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);
} }
@ -120,7 +122,6 @@ SV.registerLayout('BinaryTree', {
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,