Why graphs / graph based algorithms

algorithmsgraph theory

Not sure if this is more related to computer science but, at first, I think a graph is a quite fundamental object in maths so I will try it first here:

Why do some (or a lot) algorithms utilize graphs? I'm quite familiar with graphs and the underlying framework but I just wonder if there is a (mathematical) reason which make them better suited?
I can understand that when people implement an algorithm on different ways and figure out a graph structure is more promising – but nevertheless I feel graphs are quite popular for several reasons and not only because they provide the best results. There are probably more "theoretical" reasons I assume?
Are there?

Best Answer

This is largely based on the problem, and there are plenty of interesting problems unrelated to graphs. But, from a computer science standpoint, I would argue that graphs are of particular interest as a powerful data structure which encapsulates other data structures as special cases.

Data structures store elements and, at best, a rudimentary order or relation of those elements. For example: (1) an ascending order of elements in an array or linked list, or (2) a parent/child relationship maintained by a tree. A graph stores elements as nodes and additionally edge objects give the ability to store any number of relation between elements, as well as varying types of relations since edges themselves can hold information (such as weight, ID, and other attributes). In this sense, linked-lists are a special kind of graph where each element is a node and has an unweighted edge to the node before/after it. Similarly, a tree is a particular kind of graph where each element has an unweighted edge to a parent and all children elements. A graph then allows for a great degree of freedom when describing how elements are related.

Related Question