diff options
| author | haoyuren <13851610112@163.com> | 2026-03-11 14:12:12 -0500 |
|---|---|---|
| committer | haoyuren <13851610112@163.com> | 2026-03-11 14:12:12 -0500 |
| commit | 9994e69593de206a7cd8670f027de3af7ba2f33f (patch) | |
| tree | e10ad08979eab5c9a60a68a806971b4765744078 /index.html | |
| parent | 975fe4de28d0c0aacb89a9709dd6f82abb47b398 (diff) | |
Fix community label: only use node tags + me-connected edge relations
Exclude relation tags between other people. Only count:
1. node.tags (personal tags like location, occupation)
2. relations on edges connecting each person to "me"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'index.html')
| -rw-r--r-- | index.html | 41 |
1 files changed, 18 insertions, 23 deletions
@@ -3192,25 +3192,27 @@ function convexHullPadded(points, padding) { function communityAutoLabel(memberIds, allCommunityGroups) { const memberSet = new Set(memberIds); - // Collect all tags for each community: node tags + edge relation tags (internal edges) - const tagInternalCount = {}; // tag -> count within this community - const tagTotalCount = {}; // tag -> count across all communities + // Tag sources: node.tags + relations on edges connected to "me" + function getNodeTags(id) { + const node = data.nodes.find(n => n.id === id); + const tags = [...(node?.tags || [])]; + // Add relation tags from edges connecting this node to "me" + data.edges.forEach(e => { + const s = typeof e.source === 'object' ? e.source.id : e.source; + const t = typeof e.target === 'object' ? e.target.id : e.target; + if ((s === 'me' && t === id) || (t === 'me' && s === id)) { + (e.relations || []).forEach(r => tags.push(r)); + } + }); + return tags; + } // Precompute total counts for all tags across all communities const allTagTotal = {}; for (const [, members] of Object.entries(allCommunityGroups)) { - const mSet = new Set(members); - const seen = {}; // tag -> count in this community + const seen = {}; members.forEach(id => { - const node = data.nodes.find(n => n.id === id); - if (node) (node.tags || []).forEach(t => { seen[t] = (seen[t] || 0) + 1; }); - }); - data.edges.forEach(e => { - const s = typeof e.source === 'object' ? e.source.id : e.source; - const t = typeof e.target === 'object' ? e.target.id : e.target; - if (mSet.has(s) && mSet.has(t)) { - (e.relations || []).forEach(r => { seen[r] = (seen[r] || 0) + 1; }); - } + getNodeTags(id).forEach(t => { seen[t] = (seen[t] || 0) + 1; }); }); for (const [t, c] of Object.entries(seen)) { allTagTotal[t] = (allTagTotal[t] || 0) + c; @@ -3218,16 +3220,9 @@ function communityAutoLabel(memberIds, allCommunityGroups) { } // Count tags within this community + const tagInternalCount = {}; memberIds.forEach(id => { - const node = data.nodes.find(n => n.id === id); - if (node) (node.tags || []).forEach(t => { tagInternalCount[t] = (tagInternalCount[t] || 0) + 1; }); - }); - data.edges.forEach(e => { - const s = typeof e.source === 'object' ? e.source.id : e.source; - const t = typeof e.target === 'object' ? e.target.id : e.target; - if (memberSet.has(s) && memberSet.has(t)) { - (e.relations || []).forEach(r => { tagInternalCount[r] = (tagInternalCount[r] || 0) + 1; }); - } + getNodeTags(id).forEach(t => { tagInternalCount[t] = (tagInternalCount[t] || 0) + 1; }); }); // Score = coverage × specificity |
