Visualizing a small graph with networkx and matplotlib
When the graph is small enough, such as the ones represented in the previous screenshots (Figure 5.2 and 5.3), it can be convenient to visualize them using the matplotlib
plotting library. In this section, we are going to reproduce the visualizations displayed previously.
When dealing with graphs in Python, fortunately, we do not have to create our own data structure and implement our algorithms. As with many other tasks, we can just pip install
a package developed by the fantastic open source community around Python. For graphs, the most used package is called networkx
. Let’s go ahead and go through our next Jupyter notebook.
Visualizing a graph with known coordinates
In this section, we are going to draw a graph representing a part of the road network around the Colosseum in Rome. This data was extracted using the osmnx
package, but we are not going to detail its extraction process here, even if osmnx
makes it...