Graphs can be effectively used to model and solve routing problems through road and public transit networks. Graphs can be designed to model and predict financial transactions and even complex social networks (yeah, blame a graph algorithm the next time Facebook or LinkedIn makes an unfamiliar or unsolicited friend suggestion or professional connection). Despite its versatility, the graph universe is made up of just two simple, easily relatable components, namely, nodes and edges. In a road network, a node might represent a road intersection and an edge might very well represent the road segment itself. The convention is that an edge is an entity that always connects two nodes, as is represented in the following diagram:
Let's fire up a new Google Colab Notebook and build our first graph using a Python library known as networkx...