pythongraphnetworkxpyvis

Change graph layout (aka. node positioning algorithm) in pyvis


When using networkx.draw() it is possible to specify different node positioning algorithms that change the graph layout using the pos keyword argument. For example:

import networkx as nx
import matplotlib.pyplot as plt

# create a graph
G = nx.dodecahedral_graph()

# draw with different layouts
plt.figure()
nx.draw(G,pos=nx.circular_layout(G))
plt.figure()
nx.draw(G,pos=nx.spring_layout(G))

gives you these two different layouts:

enter image description here enter image description here

Is it possible to do this using pyvis?


Solution

  • Yes, mainly there are four types:

    you can check their effects by setting the option show_buttons(filter_=["physics"]):

    net = Network(...)
    net.show_buttons(filter_=["physics"])
    

    on the drop-down that appears (the option 'solver')