networkx.drawing.layout.kamada_kawai_layout¶

kamada_kawai_layout
(G, dist=None, pos=None, weight='weight', scale=1, center=None, dim=2)[source]¶ Position nodes using KamadaKawai pathlength costfunction.
 Parameters
G (NetworkX graph or list of nodes) – A position will be assigned to every node in G.
dist (dict (default=None)) – A twolevel 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 (arraylike or None) – Coordinate pair around which to center the layout.
dim (int) – Dimension of layout.
 Returns
pos – A dictionary of positions keyed by node
 Return type
Examples
>>> G = nx.path_graph(4) >>> pos = nx.kamada_kawai_layout(G)