merge parallel edges in graph visualization; update link representation to include combined types and max count
This commit is contained in:
parent
e2e39f2836
commit
3c436b0992
1 changed files with 17 additions and 3 deletions
20
admin.html
20
admin.html
|
|
@ -1346,10 +1346,24 @@ function renderIntelGraph() {
|
||||||
|
|
||||||
// deep-copy so d3 doesnt mutate our stored arrays on re-render
|
// deep-copy so d3 doesnt mutate our stored arrays on re-render
|
||||||
const nodesCopy = nodes.map(n => ({ ...n }));
|
const nodesCopy = nodes.map(n => ({ ...n }));
|
||||||
const linksCopy = links.map(l => ({
|
|
||||||
|
// merge parallel edges (same src+tgt pair) into one — concat labels, take max count
|
||||||
|
const edgeMap = new Map();
|
||||||
|
for (const l of links) {
|
||||||
|
const src = typeof l.source === 'object' ? l.source.key : l.source;
|
||||||
|
const tgt = typeof l.target === 'object' ? l.target.key : l.target;
|
||||||
|
const key = `${src}||${tgt}`;
|
||||||
|
if (edgeMap.has(key)) {
|
||||||
|
const existing = edgeMap.get(key);
|
||||||
|
if (!existing.types.includes(l.type)) existing.types.push(l.type);
|
||||||
|
existing.count = Math.max(existing.count, l.count || 1);
|
||||||
|
} else {
|
||||||
|
edgeMap.set(key, { source: src, target: tgt, types: [l.type], count: l.count || 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const linksCopy = Array.from(edgeMap.values()).map(l => ({
|
||||||
...l,
|
...l,
|
||||||
source: typeof l.source === 'object' ? l.source.key : l.source,
|
type: l.types.join(' · '),
|
||||||
target: typeof l.target === 'object' ? l.target.key : l.target,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const svgEl = document.getElementById('intel-graph-svg');
|
const svgEl = document.getElementById('intel-graph-svg');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue