Skip to main content
`Ctrl`+`K`

# kamada_kawai_layout

kamada_kawai_layout(G, dist=None, pos=None, weight='weight', scale=1, center=None, dim=2)

  Position nodes using Kamada-Kawai path-length cost-function.

  Parameters:
    G NetworkX graph or list of nodes

      A position will be assigned to every node in G.

    dist dict (default=None)

      A two-level dictionary of optimal distances between nodes, indexed by source and destination node. If None, the distance is computed using shortest_path_length().

    pos dict or None optional (default=None)

      Initial positions for nodes as a dictionary with node as keys and values as a coordinate list or tuple. If None, then use circular_layout() for dim >= 2 and a linear layout for dim == 1.

    weight string or None optional (default=’weight’)

      The edge attribute that holds the numerical value used for the edge weight. If None, then all edge weights are 1.

    scale number (default: 1)

      Scale factor for positions.

    center array-like or None

      Coordinate pair around which to center the layout.

    dim int

      Dimension of layout.

  Returns:
    pos dict

      A dictionary of positions keyed by node

  Examples

      >>> G = nx.path_graph(4)
      >>> pos = nx.kamada_kawai_layout(G)