@graphty/layout
Version:
graph layout algorithms based on networkx
23 lines • 1.09 kB
JavaScript
/**
* Spring layout algorithm (Fruchterman-Reingold variant)
*/
import { fruchtermanReingoldLayout } from './fruchterman-reingold';
/**
* Position nodes using Fruchterman-Reingold force-directed algorithm.
*
* @param {Object} G - Graph or list of nodes
* @param {number} k - Optimal distance between nodes
* @param {Object} pos - Initial positions for nodes
* @param {Array} fixed - Nodes to keep fixed at initial position
* @param {number} iterations - Maximum number of iterations
* @param {number} scale - Scale factor for positions
* @param {Array|null} center - Coordinate pair around which to center the layout
* @param {number} dim - Dimension of layout
* @param {number} seed - Random seed for initial positions
* @returns {Object} Positions dictionary keyed by node
*/
export function springLayout(G, k = null, pos = null, fixed = null, iterations = 50, scale = 1, center = null, dim = 2, seed = null) {
// Legacy compatibility alias
return fruchtermanReingoldLayout(G, k, pos, fixed, iterations, scale, center, dim, seed);
}
//# sourceMappingURL=spring.js.map