scirpy.util.graph.layout_fr_size_aware(graph, *, k=None, scale=None, origin=None, total_iterations=50, initial_temperature=1.0, node_positions=None, fixed_nodes=None, base_node_size=0.01, size_power=0.5)#

Compute the Fruchterman-Reingold layout respecting node sizes.

Adapted from

  • graph (Graph) –

    igraph object to compute the layout for. Respects the vertex attribute “size”, if available.

    Providing the correct node size minimises the overlap of nodes in the graph, which can otherwise occur if there are many nodes, or if the nodes differ considerably in size.

  • k (Optional[float] (default: None)) – Expected mean edge length. If None, initialized to the sqrt(area / total nodes).

  • scale (Optional[tuple[float, float]] (default: None)) –

    (float delta x, float delta y) or None (default None -> (1, 1))

    The width and height of the bounding box specifying the extent of the layout. If None is given, the scale is set to (1, 1).

  • origin (Optional[tuple[float, float]] (default: None)) –

    (float x, float y) tuple or None (default None -> (0, 0))

    The lower left hand corner of the bounding box specifying the extent of the layout. If None is given, the origin is placed at (0, 0).

  • total_iterations (int (default: 50)) – Number of iterations.

  • initial_temperature (float (default: 1.0)) – Temperature controls the maximum node displacement on each iteration. Temperature is decreased on each iteration to eventually force the algorithm into a particular solution. The size of the initial temperature determines how quickly that happens. Values should be much smaller than the values of scale.

  • node_positions (Optional[Mapping[int, tuple[float, float]]] (default: None)) –

    dict key : (float, float) or None (default None)

    Mapping of nodes to their (initial) x,y positions. If None are given, nodes are initially placed randomly within the bounding box defined by origin and scale.

  • fixed_nodes (Optional[Sequence] (default: None)) – Nodes to keep fixed at their initial positions.

Return type:



node_positions n_nodex - dim array containing the layout positions