|
const limbSeq = [ |
|
[1, 2], [2, 3], [3, 4], |
|
[1, 5], [5, 6], [6, 7], |
|
[1, 8], [8, 9], [9, 10], |
|
[1, 11], [11, 12], [12, 13], |
|
[1, 0], |
|
[0, 14], [14, 16], |
|
[0, 15], [15, 17] |
|
]; |
|
|
|
let parentNodeIndices = Array(18).fill(-1); |
|
let childNodeIndices = Array(18).fill(-1); |
|
let outEdgeIndices = Array(18).fill(-1); |
|
let inEdgeIndices = Array(18).fill(-1); |
|
|
|
function initializeLimb() { |
|
limbSeq.forEach((limb, i) => { |
|
parentNodeIndices[limb[1]] = limb[0]; |
|
childNodeIndices[limb[0]] = limb[1]; |
|
outEdgeIndices[limb[0]] = i; |
|
inEdgeIndices[limb[1]] = i; |
|
}); |
|
} |
|
|
|
function findParentNodeIndex(nodeIndex) { |
|
return parentNodeIndices[nodeIndex]; |
|
} |
|
|
|
function findChildNodeIndex(nodeIndex) { |
|
return childNodeIndices[nodeIndex]; |
|
} |
|
|
|
function findOutEdgeIndex(nodeIndex) { |
|
return outEdgeIndices[nodeIndex]; |
|
} |
|
|
|
function findInEdgeIndex(nodeIndex) { |
|
return inEdgeIndices[nodeIndex]; |
|
} |
|
|
|
function findNextEdgeIndex(edgeIndex) { |
|
return findOutEdgeIndex(limbSeq[edgeIndex][1]); |
|
} |
|
|
|
function findPrevEdgeIndex(edgeIndex) { |
|
return findInEdgeIndex(limbSeq[edgeIndex][0]); |
|
} |
|
|
|
initializeLimb(); |
|
|