(nodes, edges)
| 3508 | } |
| 3509 | |
| 3510 | function buildWikiMap(nodes, edges) { |
| 3511 | const sourceNodes = (nodes || []).filter((node) => graphId(node).trim()); |
| 3512 | const sourceEdges = (edges || []).map(normalizeGraphEdge); |
| 3513 | const sourceById = Object.fromEntries(sourceNodes.map((node) => [graphId(node), node])); |
| 3514 | const entries = conceptEntriesFromGraph(sourceNodes, sourceEdges); |
| 3515 | const topPapers = topPaperNodes(sourceNodes, sourceEdges, 4); |
| 3516 | const userNodes = sourceNodes.filter((node) => graphType(node) === "frontier" || graphId(node).startsWith("user:")); |
| 3517 | |
| 3518 | if (!sourceNodes.length) { |
| 3519 | return { nodes: [], edges: [], sourceNodes, sourceEdges, byId: {} }; |
| 3520 | } |
| 3521 | |
| 3522 | const coreNode = { |
| 3523 | id: "architecture:core", |
| 3524 | node_id: "architecture:core", |
| 3525 | title: ui().wiki.architecture, |
| 3526 | node_type: "topic", |
| 3527 | type: "topic", |
| 3528 | x: 50, |
| 3529 | y: 49, |
| 3530 | size: "core", |
| 3531 | body: architectureBody(ui().wiki.architecture, sourceNodes, sourceEdges, entries, topPapers), |
| 3532 | real_node_id: "", |
| 3533 | source_count: sourceNodes.length, |
| 3534 | related_papers: topPapers |
| 3535 | }; |
| 3536 | |
| 3537 | const userNode = { |
| 3538 | id: "architecture:user-direction", |
| 3539 | node_id: "architecture:user-direction", |
| 3540 | title: state.locale === "en" ? "User Direction" : "用户方向", |
| 3541 | node_type: "frontier", |
| 3542 | type: "frontier", |
| 3543 | x: 50, |
| 3544 | y: 72, |
| 3545 | size: "medium", |
| 3546 | body: userDirectionBody(userNodes, topPapers, entries), |
| 3547 | real_node_id: "", |
| 3548 | source_count: userNodes.length, |
| 3549 | related_papers: topPapers |
| 3550 | }; |
| 3551 | |
| 3552 | const topicEntries = entries.slice(0, 4); |
| 3553 | const topicLabels = new Set(topicEntries.map((entry) => entry.label)); |
| 3554 | const methodEntries = entries |
| 3555 | .filter((entry) => !topicLabels.has(entry.label)) |
| 3556 | .filter((entry) => /(search|routing|editing|cache|efficiency|grounding|learning|检索|编辑|效率|推理)/i.test(entry.label)) |
| 3557 | .concat(entries.filter((entry) => !topicLabels.has(entry.label))) |
| 3558 | .filter((entry, index, arr) => arr.findIndex((item) => item.label === entry.label) === index) |
| 3559 | .slice(0, 3); |
| 3560 | |
| 3561 | const topicNodes = topicEntries.map((entry, index) => { |
| 3562 | const position = topicPositions[index] || topicPositions[topicPositions.length - 1]; |
| 3563 | const relatedPapers = relatedPapersForEntry(entry, sourceById, sourceEdges, topPapers); |
| 3564 | return { |
| 3565 | id: `architecture:topic:${slugLabel(entry.label)}`, |
| 3566 | node_id: `architecture:topic:${slugLabel(entry.label)}`, |
| 3567 | title: entry.label, |
nothing calls this directly
no test coverage detected