From 9994e69593de206a7cd8670f027de3af7ba2f33f Mon Sep 17 00:00:00 2001 From: haoyuren <13851610112@163.com> Date: Wed, 11 Mar 2026 14:12:12 -0500 Subject: 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 --- index.html | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index 11014fa..958dd8f 100644 --- a/index.html +++ b/index.html @@ -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 -- cgit v1.2.3