hm
This commit is contained in:
parent
7455d630fc
commit
4d3fc2cd47
84 changed files with 3429 additions and 3480 deletions
|
|
@ -5,23 +5,12 @@ function lineageEdgeFamily(family = world.family || {}) {
|
|||
|
||||
let lineageRelationIndexCache = { family: null, version: null, index: null };
|
||||
|
||||
function lineageAddParentEdge(childId, parentId, known, parentsByChild, childrenByParent) {
|
||||
return globalThis.TarinaiFamilyGraph.addParentEdge(childId, parentId, known, parentsByChild, childrenByParent);
|
||||
}
|
||||
|
||||
function lineageBuildRelationIndex(family) {
|
||||
const known = new Set(Object.keys(family || {}));
|
||||
const parentsByChild = new Map();
|
||||
const childrenByParent = new Map();
|
||||
const addParent = (childId, parentId) => {
|
||||
if (!childId || !parentId || childId === parentId || !known.has(childId) || !known.has(parentId)) return;
|
||||
if (!parentsByChild.has(childId)) parentsByChild.set(childId, new Set());
|
||||
if (!childrenByParent.has(parentId)) childrenByParent.set(parentId, new Set());
|
||||
parentsByChild.get(childId).add(parentId);
|
||||
childrenByParent.get(parentId).add(childId);
|
||||
};
|
||||
for (const n of Object.values(family || {})) {
|
||||
if (!n?.id) continue;
|
||||
for (const parentId of n.parents || []) addParent(n.id, parentId);
|
||||
for (const childId of n.children || []) addParent(childId, n.id);
|
||||
}
|
||||
return { parentsByChild, childrenByParent };
|
||||
return globalThis.TarinaiFamilyGraph.buildRelationIndex(family);
|
||||
}
|
||||
|
||||
function lineageRelationIndex(family = world.family || {}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue