class_docstr: 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 :math:`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.
code: def _fruchterman_reingold(self, adjacency_mat, directed=False):
      if self.optimal is None:
          self.optimal = 1 / np.sqrt(self.num_nodes)
  
      if self.pos is None:
          # Random initial positions
          pos = np.asarray(
              np.random.random((self.num_nodes, self.dim)),
              dtype=np.float32,
          )
      else:
          pos = self.pos.astype(np.float32)
  
      # Yield initial positions
      line_vertices, arrows = _straight_line_vertices(
          adjacency_mat, pos, directed
      )
      yield pos, line_vertices, arrows
  
      # The initial "temperature"  is about .1 of domain area (=1x1)
      # this is the largest step allowed in the dynamics.
      t = 0.1
  
      # Simple cooling scheme.
      # Linearly step down by dt on each iteration so last iteration is
      # size dt.
      dt = t / float(self.iterations + 1)
      # The inscrutable (but fast) version
      # This is still O(V^2)
      # Could use multilevel methods to speed this up significantly
      for iteration in range(self.iterations):
          delta_pos = _calculate_delta_pos(
              adjacency_mat, pos, t, self.optimal
          )
          pos += delta_pos
          _rescale_layout(pos)
  
          # cool temperature
          t -= dt
  
          # Calculate edge vertices and arrows
          line_vertices, arrows = _straight_line_vertices(
              adjacency_mat, pos, directed
          )
  
          yield pos, line_vertices, arrows
  
file_path: vispy/vispy/visuals/graphs/layouts/force_directed.py
imports: import numpy
  from ..util import _straight_line_vertices, _rescale_layout
label_desc: Use image node_id 3 for calling the fruchterman_reingold obj's underlying member method code with example usage: obj._fruchterman_reingold(adjacency_mat, directed) without return types