Skip to main content
`Ctrl`+`K`

# vispy.visuals.graphs.layouts.force_directed module

## Force-Directed Graph Layout

This module contains implementations for a force-directed layout, where the graph is modelled like a collection of springs or as a collection of particles attracting and repelling each other. The whole graph tries to reach a state which requires the minimum energy.

class vispy.visuals.graphs.layouts.force_directed.fruchterman_reingold(optimal=None, iterations=50, pos=None)

  Bases: `object`

  Fruchterman-Reingold implementation adapted from NetworkX.

  In the Fruchterman-Reingold algorithm, the whole graph is modelled as a collection of particles, it runs a simplified particle simulation to find a nice layout for the graph.

  Parameters:
    optimal number

      Optimal distance between nodes. Defaults to 1/\\sqrt{N} where N is the number of nodes.

    iterations int

      Number of iterations to perform for layout calculation.

    pos array

      Initial positions of the nodes

  Notes

  The algorithm is explained in more detail in the original paper [1].

  [1]

  Fruchterman, Thomas MJ, and Edward M. Reingold. “Graph drawing by force-directed placement.” Softw., Pract. Exper. 21.11 (1991), 1129-1164.