How to build graphs well in Python

As part of my user interface, I want to display graphs. Requirements:

  • The graph should respond to events (for example, mouse clicks).
  • If the graph is directed, I need beautiful arrows.
  • If there are multiple edges spanning two nodes, I want to display multiple edges.
  • The layout should be nice.

Now there are two libraries: networkx and graphviz, which can perform some of these actions. networkx can do 1 and (with some large hacks) 2. graphviz can do 2 and 3. 4 can be executed by any library.

I would prefer to use graphviz because it will eliminate some dependencies; however, his inability to interact with matplotlib is a serious problem.

Therefore, at the moment I am stuck in the network, I need to use the hack arrows and abandon the idea of ​​parallel edges.

My question is: is it a modern level or is there some other approach that I could try?

Another question: is it better to use another language to visualize the graph? For example, does it make sense to move the entire interface / visualization to JavaScript, keeping Python just for data analysis?

+4
source share

Source: https://habr.com/ru/post/1606761/


All Articles