You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
4.9 KiB

4 months ago
import type { PathStyleProps } from '@antv/g';
import type { RuntimeContext } from '../runtime/types';
import type { EdgeData } from '../spec';
import type { ID } from '../types';
import type { BaseTransformOptions } from './base-transform';
import { BaseTransform } from './base-transform';
import type { DrawData } from './types';
export interface ProcessParallelEdgesOptions extends BaseTransformOptions {
/**
* <zh/>
* - `'merge'`:
* - '`bundle`': 线线
*
* <en/> Processing mode
* - '`merge`': Merge parallel edges into one edge which is suitable for cases where parallel edges do not need to be distinguished
* - '`bundle`': Each edge will be bundled with all other parallel edges and separated from them by varying the curvature. If the number of parallel edges in a group is odd, the central edge will be drawn as a straight line, and the others will be drawn as curves
* @defaultValue 'bundle'
*/
mode: 'bundle' | 'merge';
/**
* <zh/>
*
* <en/> The edges to be handled, all edges by default
*/
edges?: ID[];
/**
* <zh/>
*
* <en/> The distance between edges, only valid for bundling mode
*/
distance?: number;
/**
* <zh/>
*
* <en/> The style of the merged edge, only valid for merging mode
*/
style?: PathStyleProps | ((prev: EdgeData[]) => PathStyleProps);
}
/**
* <zh/>
*
* <en/> Process parallel edges which share the same source and target nodes
* @remarks
* <zh/> Parallel Edges(1) bundle(2) merge
*
* <en/> Parallel Edges refer to multiple edges existing between two nodes in a graph structure. These edges share the same source and target nodes but may represent different relationships or attributes. To avoid edge overlap and confusion, two methods are provided for handling parallel edges: (1) Bundle Mode: Bundles parallel edges together and separates them from other edges by altering their curvature; (2) Merge Mode: Merges parallel edges into a single aggregated edge.
*/
export declare class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOptions> {
static defaultOptions: Partial<ProcessParallelEdgesOptions>;
private cacheMergeStyle;
constructor(context: RuntimeContext, options: ProcessParallelEdgesOptions);
/**
* <zh/>
*
* <en/> Process parallel edges before each drawing
* @param input
*/
beforeDraw(input: DrawData): DrawData;
/**
* <zh/>
*
* <en/> Get affected parallel edges
* @param input
*/
private getAffectedParallelEdges;
protected applyBundlingStyle: (input: DrawData, edges: Map<ID, EdgeData>, distance: number) => void;
private resetEdgeStyle;
protected applyMergingStyle: (input: DrawData, edges: Map<ID, EdgeData>) => void;
}
/**
* <zh/> O(n)
*
* <en/> Optimized method to group by endpoints, time complexity O(n)
* @param edges - <zh/> | <en/> Edges
* @returns <zh/> | <en/> Edges grouped by endpoints
*/
export declare const groupByEndpoints: (edges: Map<ID, EdgeData>) => {
edgeMap: Map<string, EdgeData[]>;
reverses: Record<string, boolean>;
};
/**
* <zh/>
*
* <en/> Get parallel edges
* @param edge - <zh/> | <en/> Target edge
* @param edges - <zh/> | <en/> Edges
* @param containsSelf - <zh/> | <en/> Whether the output result contains the target edge
* @returns <zh/> | <en/> Parallel edges
*/
export declare const getParallelEdges: (edge: EdgeData, edges: EdgeData[], containsSelf?: boolean) => EdgeData[];
/**
* <zh/>
*
* <en/> Determine whether two edges are parallel
* @param edge1 - <zh/> 1 | <en/> Edge 1
* @param edge2 - <zh/> 2 | <en/> Edge 2
* @returns <zh/> | <en/> Whether is parallel
*/
export declare const isParallelEdges: (edge1: EdgeData, edge2: EdgeData) => boolean;