()
| 4053 | const type = graphType(node); |
| 4054 | (groups[type] || groups.topic).nodes.push(node); |
| 4055 | }); |
| 4056 | |
| 4057 | const mapNodes = []; |
| 4058 | Object.entries(groups).forEach(([type, group]) => { |
| 4059 | const count = Math.max(1, group.nodes.length); |
| 4060 | group.nodes.forEach((node, index) => { |
| 4061 | const ring = Math.floor(index / 18); |
| 4062 | const slot = index % 18; |
| 4063 | const angle = (slot / Math.min(18, count)) * Math.PI * 2 + ring * 0.38; |
| 4064 | const radiusX = 7 + ring * 6 + (type === "paper" ? 3 : 0); |
| 4065 | const radiusY = 6 + ring * 4.5 + (type === "paper" ? 2 : 0); |
| 4066 | const id = graphId(node); |
| 4067 | const score = degree[id] || 0; |
| 4068 | mapNodes.push({ |
| 4069 | ...node, |
| 4070 | id, |
| 4071 | node_id: id, |
| 4072 | type, |
| 4073 | x: clamp(group.x + Math.cos(angle) * radiusX, 5, 94), |
| 4074 | y: clamp(group.y + Math.sin(angle) * radiusY, 8, 91), |
| 4075 | size: score >= 2.5 ? "large" : score >= 1.0 ? "medium" : "small", |
| 4076 | real_node_id: id |
| 4077 | }); |
| 4078 | }); |
| 4079 | }); |
| 4080 | const map = { |
| 4081 | nodes: mapNodes, |
| 4082 | edges: sourceEdges, |
| 4083 | sourceNodes, |
| 4084 | sourceEdges, |
| 4085 | byId: Object.fromEntries(mapNodes.map((node) => [node.id, node])) |
| 4086 | }; |
| 4087 | state.wikiMap = map; |
| 4088 | const focusId = state.currentWikiNodeId && map.byId[state.currentWikiNodeId] |
| 4089 | ? state.currentWikiNodeId |
| 4090 | : pickWikiFocusNodeId(); |
| 4091 | return { |
| 4092 | nodes: map.nodes.map((node) => ({ ...node, x: node.x, y: node.y, type: node.type, size: node.size })), |
| 4093 | edges: map.edges, |
| 4094 | centerId: focusId || graphId(map.nodes[0] || {}), |
| 4095 | sourceCount: map.sourceNodes.length, |
| 4096 | sourceEdgeCount: map.sourceEdges.length |
| 4097 | }; |
| 4098 | } |
| 4099 |
no test coverage detected