UNPKG

@graphty/layout

Version:

graph layout algorithms based on networkx

23 lines (22 loc) 1.45 kB
import type { Graph, Node, PositionMap } from '../../types'; /** * Position nodes using the ForceAtlas2 force-directed algorithm. * * @param G - Graph * @param pos - Initial positions for nodes * @param maxIter - Maximum number of iterations * @param jitterTolerance - Controls tolerance for node speed adjustments * @param scalingRatio - Scaling of attraction and repulsion forces * @param gravity - Attraction to center to prevent disconnected components from drifting * @param distributedAction - Distributes attraction force among nodes * @param strongGravity - Uses a stronger gravity model * @param nodeMass - Dictionary mapping nodes to their masses * @param nodeSize - Dictionary mapping nodes to their sizes * @param weight - Edge attribute for weight * @param dissuadeHubs - Whether to prevent hub nodes from clustering * @param linlog - Whether to use logarithmic attraction * @param seed - Random seed for initial positions * @param dim - Dimension of layout * @returns Positions dictionary keyed by node */ export declare function forceatlas2Layout(G: Graph, pos?: PositionMap | null, maxIter?: number, jitterTolerance?: number, scalingRatio?: number, gravity?: number, distributedAction?: boolean, strongGravity?: boolean, nodeMass?: Record<Node, number> | null, nodeSize?: Record<Node, number> | null, weight?: string | null, dissuadeHubs?: boolean, linlog?: boolean, seed?: number | null, dim?: number): PositionMap;