Common Graph Theory Problems
By: Kelvin Jose
Tags: Graph Theory, Mathematical Modeling, Graph Theory Simplified, Machine Learning, Graph

Common Graph Theory Problems

A lot of problems we encounter every day could be paraphrased to a graph problem or a near similar subproblem. So it’s required to have some familiarity with different graph variations and their applications. If you want to brush up the basics of Graph Theory - once again, you should definitely visit this. The latter will give you a brief idea about different types of Graphs and their representations.

Shortest Path Problem

One of the most common Graph problems is none other than the Shortest Path Problem. Given a weighted graph, we have to figure out the shorted path from node A to G. The shorted path out of all possible paths would definitely the one which optimizes a cost function.

Photo by Author

For instance, consider the nodes of the above given graph are different cities around the world. If you closely observe the figure, we could see a cost associated with each edge. So it’s a directed - weighted graph. Coming back to our intuition, the weights associated with each pair of cities are considered as the costs to travel between cities. To make it more convenient, let’s multiply each cost with 100$ to get a real world figure. So, the cost to travel between cities A and B is 300$, the cost between B and F is 600$ and so on. If we want to plan a cost efficient journey between two cities, we should consult this graph to estimate the overall cost. There might be multiple paths between two cities, the path we seek the most would be the one which reduces the cost to the lowest. This is a really basic but understandable example of a shortest path problem.

Luckily there exists a couple of algorithms which may lead us from node A to B with minimal cost. Breadth First Search, Dijksra’s, Bellman - Ford, Floyd - Warshall, A* and many more algorithms are available to solve shortest path problems.

Connectivity

As simple as the name suggests, connectivity is a big issue in Graph Theory which indicates does there a path exist from node A to B. One thing to be noted is, we don’t care about the minimum cost but only a path.

Photo by Author

The most basic approach to solve this problem is to do either a Breadth First Search or a Depth First Search.

Negative Cycles

Sometimes our graph would have negative edges which can rip off the entire flow of the graph. I would say a negative cycle is a never ending trap. So we examine, whether there exist a negative weighted edge between any pair of nodes and if so how does it form a cycle.

Photo by Author

There is a negative edge residing in the given graph. Obviously, it makes a contribution to the formation of negative cycles. One such cycle is (B, C, D). If we cycle through these edges, we would go endless having minimum cost, forever. Still, there are some contexts where negative cycles play an angel role. For example, if we run a money exchange game from one currency to another currency and to another, we could employ such a negative graph which in turn might produce some cost benefits. This is just a hypothesis and may or may not become true, because currency rates would not stay the same for so long. There are certain algorithms such as Bellman - Ford and Floyd - Warshall to detect negative cycles.

Strongly Connected Components

These are self contained cycles with in a directed graph, so that - each node in the cycle can reach all other nodes in the same cycle.

Photo by Author

It’s important to see whether there are strongly connected components or not. The cycles enclosed within the red boxes are the examples of such components. Different algorithms used to detect these components are Tarjan’s and Kosaraju’s algorithms.

Traveling Salesman Problem

Nobody would have completed their CS degree without hearing this term. I’m so sorry about if you didn’t. But it’s completely easy to understand and have lots of real world applications.

Photo from Essay Corp Blog

The problem is structured as given a list of cities and costs or distance between every possible pair of cities. Then a salesman has to start and finish at the same node, but have to visit each and every city exactly once in the trajectory with minimum cost or distance - depending upon the target function. The problem looks really straightforward and has got wide attention in path estimation and cost optimization problems. Several algorithms such as branch and bound and Held - Karp are available to solve this problem. This is still a computationally challenging but research continuing problem.

Bridges

Bridges are edges in a graph whose removal could increase the number of connected components in the graph. Bridges are really important because they represent the vulnerabilities and bottlenecks with in the graph.

Photo by onion-router.net

Removing the edge that connects the nodes G and N would result in two individual components which are connected. If that’s a real bridge, demolishing it would result in two isolated cities. So, a bridge is always a weak point because it’s disconnection would make additional pain points.

Similarly, an articulation point is a node whose removal causes an increase in the total number of connected components.

Minimum Spanning Tree

A minimum spanning tree is a subset of the edges which connect all the vertices together to form a tree of minimum cost.

As you can see the given graph is weighted and undirected. The bolder edges show the minimum cost spanning tree which connects all the vertices, but in a minimum cost. We formulate different problems such as route planning, circuit designing and a lot more as a Minimum Spanning Tree which could be solved by Kruskal’s and Prim’s algorithms.

Maximum Network Flow

As the name shows, these problems can be used to estimate the maximum volume (depending on the problem) a graph can accommodate. For example, if we consider the electricity network as our graph and the utility poles as the different nodes in the graph. We can have assumptions on how much electricity could be sent over the network without affecting the power grid. Another example is a mobile network where each user acts as a node in the graph. As in the former example, we can figure out the maximum number of users who can stay online without network traffic.

Photo by Author

This formulation can answer the maximum of all and predict potential bottlenecks. Different algorithms used are Ford-Fulkerson and Edmonds Karp & Dinic’s algorithms.

We have covered almost every problem in graph theory. We will discuss each and every algorithm mentioned here in the coming posts. I’m super excited to share all of them with you. Until then, see ya!