Welcome to Think Like A Programmer, where we break down complicated computer science concepts into bite-sized articles for you. In today’s article, we’ll be looking at graphs - a data structure which can be used to represent connections or relationships between different objects.
Personally, I think graphs are extremely useful in computer science - and they’re probably significantly more useful than you think!
Analogy
Imagine you’re going to a new theme park and you see the following map
We can mark out potential places of interest with a circle as seen below. In this example, I’ve chosen 5 random places and marked them out.
There are also some roads that connect the individual attraction so let’s use some lines to represent these roads
Each line here represents a direct path that connects the two nodes without going through another attraction
Now that we have this specific representation, what can we do with it?