()
| 3856 | } |
| 3857 | |
| 3858 | function pickWikiFocusNodeId() { |
| 3859 | const nodes = state.wikiGraph?.nodes || []; |
| 3860 | if (!nodes.length) return ""; |
| 3861 | const edges = currentGraphEdges(); |
| 3862 | const degree = graphDegreeMap(nodes, edges); |
| 3863 | const candidates = nodes.filter((node) => { |
| 3864 | const id = graphId(node); |
| 3865 | const type = graphType(node); |
| 3866 | return !id.startsWith("user:") && type !== "frontier"; |
| 3867 | }); |
| 3868 | return (candidates.length ? candidates : nodes).reduce((best, node) => { |
| 3869 | const id = graphId(node); |
| 3870 | const typeBoost = graphType(node) === "paper" ? 2.0 : graphType(node) === "topic" ? 1.2 : 0.4; |
| 3871 | const score = (degree[id] || 0) + Number(node.score || 0) + typeBoost; |
| 3872 | const bestNode = nodes.find((item) => graphId(item) === best); |
| 3873 | const bestTypeBoost = bestNode && graphType(bestNode) === "paper" ? 2.0 : bestNode && graphType(bestNode) === "topic" ? 1.2 : 0.4; |
| 3874 | const bestScore = (degree[best] || 0) + Number(bestNode?.score || 0) + bestTypeBoost; |
| 3875 | return score > bestScore ? id : best; |
| 3876 | }, graphId(candidates[0] || nodes[0])); |
| 3877 | } |
| 3878 | |
| 3879 | function wikiStatsText(stats, suffix = "") { |
| 3880 | const byType = stats.nodes_by_type || {}; |
no test coverage detected