Python NetworkX - Why are graphs always randomly rotated?

后端 未结 3 1865
旧巷少年郎
旧巷少年郎 2021-01-13 07:44

If I generate the same graph multiple times using NetworkX and Matplotlib it\'s rotated randomly on every generation:

Run 1:

Run 2:

Without changin

3条回答
  •  迷失自我
    2021-01-13 08:18

    From the docs:

    spring_layout(G, dim=2, k=None, pos=None, fixed=None, iterations=50, weight='weight', scale=1.0)
    

    pos : dict or None optional (default=None)

    Initial positions for nodes as a dictionary with node as keys and values as a list or tuple. If None, then use random initial positions.

    So if you don't specify initial positions of your nodes, NetworkX will do so at random.

    https://networkx.github.io/documentation/networkx-1.9/reference/generated/networkx.drawing.layout.spring_layout.html

提交回复
热议问题