MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / pickWikiFocusNodeId

Function pickWikiFocusNodeId

deployments/desktop/static/desktop.js:3858–3877  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 || {};

Callers 3

layoutGraphFunction · 0.85
loadWikiFunction · 0.85
bindEventsFunction · 0.85

Calls 4

currentGraphEdgesFunction · 0.85
graphDegreeMapFunction · 0.85
graphIdFunction · 0.85
graphTypeFunction · 0.85

Tested by

no test coverage detected