0

I have defined a graph by using from pyvis.network import Network and defining a network as net = Network().

I added to the net edges and nodes using the functions net.add_nodes(nodes) and net.add_edge(x, y). There is any chance to deal with this graph not only using a visualization? So for e.g. to find all paths between two specific nodes? Because searching in the documentation there is only the possibility to plot the graph. I saw other options (e.g. class) to deal with graphs (example) but is very annoying to define the graph with a dict of a dict.

Will
  • 1,619
  • 5
  • 23

1 Answers1

0

From the pyvis documentation:

The pyvis library is meant for quick generation of visual network graphs with minimal python code. It is designed as a wrapper around the popular Javascript visJS library found at this link.

You probably want a library such as networkx, which you probably have tagged by accident. It's description states

NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

This includes many operations, see the tutorial or to take your example: shortest path

Sparky05
  • 4,692
  • 1
  • 10
  • 27
  • It is better to use networkx or i-graph (https://igraph.org/python/)? – Will Dec 15 '21 at 16:57
  • I have not much experience with `igraph`, but would simply recommend that you check both documentation and check with your requirements. `Networkx` is pure python with a very good documentation. `igraph` is based on C (hence faster to run, but modification of the graph more costly). Transformation between both on the graph level are anyways available. – Sparky05 Dec 16 '21 at 08:27