mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-06 11:41:28 +00:00
removed old marker code
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function Marker({id, offset, size, children, viewBox}) {
|
||||
return (
|
||||
<marker
|
||||
className="edge-marker"
|
||||
id={id}
|
||||
viewBox={viewBox}
|
||||
refX={offset}
|
||||
refY="3.5"
|
||||
markerWidth={size}
|
||||
markerHeight={size}
|
||||
orient="auto"
|
||||
>
|
||||
{children}
|
||||
</marker>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { fromJS } from 'immutable';
|
||||
|
||||
import {
|
||||
initEdgesFromNodes,
|
||||
collapseMultiEdges,
|
||||
} from '../layouter-utils';
|
||||
|
||||
|
||||
@@ -22,20 +21,4 @@ describe('LayouterUtils', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('collapseMultiEdges', () => {
|
||||
it('should return collapsed multi-edges', () => {
|
||||
const input = fromJS({
|
||||
'a-b': { id: 'a-b', source: 'a', target: 'b' },
|
||||
'a-c': { id: 'a-c', source: 'a', target: 'c' },
|
||||
'b-a': { id: 'b-a', source: 'b', target: 'a' },
|
||||
'b-b': { id: 'b-b', source: 'b', target: 'b' },
|
||||
});
|
||||
expect(collapseMultiEdges(input).toJS()).toEqual({
|
||||
'a-b': { id: 'a-b', source: 'a', target: 'b', bidirectional: true },
|
||||
'a-c': { id: 'a-c', source: 'a', target: 'c' },
|
||||
'b-b': { id: 'b-b', source: 'b', target: 'b' },
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,26 +30,3 @@ export function initEdgesFromNodes(nodes) {
|
||||
|
||||
return edges;
|
||||
}
|
||||
|
||||
// Replaces all pairs of edges (A->B, B->A) with a single A->B edge that is marked as
|
||||
// bidirectional. We do this to prevent double rendering of edges between the same nodes.
|
||||
export function collapseMultiEdges(directedEdges) {
|
||||
let collapsedEdges = makeMap();
|
||||
|
||||
directedEdges.forEach((edge, edgeId) => {
|
||||
const source = edge.get('source');
|
||||
const target = edge.get('target');
|
||||
const reversedEdgeId = constructEdgeId(target, source);
|
||||
|
||||
if (collapsedEdges.has(reversedEdgeId)) {
|
||||
// If the edge between the same nodes with the opposite direction already exists,
|
||||
// mark it as bidirectional and don't add any other edges (making graph simple).
|
||||
collapsedEdges = collapsedEdges.setIn([reversedEdgeId, 'bidirectional'], true);
|
||||
} else {
|
||||
// Otherwise just copy the edge.
|
||||
collapsedEdges = collapsedEdges.set(edgeId, edge);
|
||||
}
|
||||
});
|
||||
|
||||
return collapsedEdges;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user