Any graph consists of the following:
A collection of vertices
A collection of edges
A vertex is a single node that represents an entity (it will depend on the problem to solve). An edge is a connection between two vertices. Consider the following image:
A simple graph example with four vertices and three edges.
How is a graph used in the real world? Imagine that we work on a social network app and we want a way to represent how people are connected in our network. We can achieve this by using a graph, where vertices represent profiles, and edges represent the connections between them.
In order to cover as many scenarios as possible, there are different types of graphs, each one serving a different purpose based on their own properties. Let's see some of the most common ones.