diff --git a/src/components/admin/KnowledgeGraph.jsx b/src/components/admin/KnowledgeGraph.jsx index fd97326..17886a9 100644 --- a/src/components/admin/KnowledgeGraph.jsx +++ b/src/components/admin/KnowledgeGraph.jsx @@ -26,6 +26,7 @@ const KnowledgeGraph = () => { const [topics, setTopics] = useState([]); const [relations, setRelations] = useState([]); + const [showExcludeNodes, setShowExcludeNodes] = useState(false); const reloadKb = useCallback(() => { Promise.all([db.getTopics(), db.getRelations()]).then(([allTopics, allRelations]) => { @@ -71,8 +72,15 @@ const KnowledgeGraph = () => { const { width, height } = dimensions; d3.select(svgRef.current).selectAll('*').remove(); - const nodes = topics.map(d => ({ ...d })); - const links = relations.map(d => ({ ...d })); + const filteredTopics = showExcludeNodes ? topics : topics.filter(t => t.learning_relevance !== 'exclude'); + const filteredTopicIds = new Set(filteredTopics.map(t => t.id)); + const filteredRelations = relations.filter(r => + filteredTopicIds.has(r.source?.id || r.source) && + filteredTopicIds.has(r.target?.id || r.target) + ); + + const nodes = filteredTopics.map(d => ({ ...d })); + const links = filteredRelations.map(d => ({ ...d })); const svg = d3.select(svgRef.current) .attr('viewBox', [0, 0, width, height]) @@ -116,6 +124,12 @@ const KnowledgeGraph = () => { .attr('fill', d => color(d.type) || '#1F5560') .attr('stroke', '#fff') .attr('stroke-width', 2) + .attr('stroke-dasharray', d => d.learning_relevance === 'exclude' ? '4,4' : 'none') + .attr('opacity', d => { + if (d.learning_relevance === 'exclude') return 0.3; + if (d.learning_relevance === 'peripheral') return 0.5; + return 1; + }) .on('click', (event, d) => { setSelectedNode(d); setIsEditing(false); @@ -392,6 +406,15 @@ Analyze this graph and return ONLY the optimized JSON object with this EXACT str
+
+
+ + +