API Reference
Complete API documentation for @graphty/layout. Every layout takes a frozen GraphSnapshot from @graphty/graph-format first and an options object second, and returns a LayoutResult: { positions, dim, n }, with dim numbers per node in node order. See Results and Options for the options every layout shares and for reading positions by node id.
Every function and type in the generated TypeDoc
Geometric Layouts
circular()- Nodes evenly spaced on a circle; over a sphere in 3Dshell()- Concentric circles, one per group of nodesspiral()- Nodes along an Archimedean spiralgrid()- Rows and columns of a lattice, in node orderrandom()- Uniformly random positions, seeded
See Geometric Layouts.
Structural Layouts
bfs()- One line per breadth-first level from a start noderadial()- Rings by hop distance from a root nodebipartite()- Two parallel lines for the two sides of a bipartite graphmultipartite()- One line per layerplanar()- No crossing edges, for planar graphs
See Structural Layouts.
Force-Directed and Spectral Layouts
forceAtlas2()- ForceAtlas2, for large and scale-free graphsfruchtermanReingold()- The Fruchterman-Reingold spring layoutkamadaKawai()- Drawing distances matched to shortest-path distancesarf()- Attractive and repulsive forcesspectral()- Eigenvectors of the graph Laplacian
See Force-Directed and Spectral.
Steppable Simulations
createSimulation()- A simulation by type ("forceatlas2","fruchtermanReingold","spring"), on the GPU when given an accelerator that implements itForceAtlas2Simulation,FruchtermanReingoldSimulation- The CPU simulationsLayoutSimulation- What every simulation implements:load(),step(),settled,setFixed(),setPosition(),dispose()LayoutAccelerator- What a GPU accelerator implementsseedPositions()- Fills theNaNrows of a position array from a seed, as the simulations do
Results and Positions
LayoutResult-{ positions, dim, n }toPositionMap(),fromPositionMap()- To and from an object keyed by node idtoPositionColumn(),fromPositionColumn()- To and from three numbers per node in scene unitsfitToBox()- Into a rectangle, keeping proportionsrescaleInPlace()- Rescale and recenter a flat array in placetoLayoutSnapshot()- The undirected snapshot of a snapshot, a layout 1.x graph object or a node list
Catalog
LAYOUTS- Every layout by name, with its one-shot function, its simulation type, the graphs and weights it accepts, its required options and its accelerator method
Deprecated
indexed- The namespace layout 1.x offered these layouts under;indexed.circulariscircular. Removed in 3.0.rescaleLayout(),rescaleLayoutDict()- UserescaleInPlace().