Graph Theory - Planarity Testing Algorithms



Planarity Testing in Graph Theory

Planarity testing is the process of determining whether a given graph can be drawn on a plane without any edges crossing. A graph is considered planar if it can be drawn such that no two edges intersect except at their endpoints. If a graph cannot be drawn in this way, it is non-planar.

Planarity testing plays an important role in fields such as circuit design, map coloring, and network topology, where avoiding edge crossings is essential for maintaining clarity. In this tutorial, we will explore various algorithms used for testing graph planarity.

Algorithms for Planarity Testing

There are several algorithms used to test the planarity of a graph. The most popular used planarity testing algorithms are −

  • Kurathowski's Theorem-Based Algorithms: These algorithms determine planarity by checking if the graph contains a subgraph that is a subdivision of either K5 (the complete graph on 5 vertices) or K3,3 (the complete bipartite graph on 6 vertices).
  • Hopcroft and Tarjan Algorithm: This algorithm is highly efficient for planarity testing, using depth-first search (DFS) to test planarity in linear time.
  • Boykov-Kolmogorov Algorithm: This algorithm uses a max-flow min-cut approach for planarity testing and is particularly useful in certain conditions to check graph planarity.

The Hopcroft and Tarjan's Algorithm

The Hopcroft and Tarjan planarity testing algorithm operates in O(n) time, where n is the number of vertices. This algorithm is based on the concept of embedding the graph in a plane, which involves drawing the graph while maintaining its structure and ensuring that no edges cross each other.

The major steps involved in the algorithm are as follows:

  • Step 1: The algorithm performs a depth-first search (DFS) traversal of the graph, marking the discovery time and low points of each vertex.
  • Step 2: During the DFS traversal, the algorithm attempts to "embed" the graph into a planar representation by exploring the vertices and edges while maintaining the DFS properties.
  • Step 3: If the graph cannot be embedded without edge crossings, it is concluded to be non-planar. Otherwise, the graph is planar.

Example of Hopcroft and Tarjan Algorithm

Let us consider a graph with 5 vertices and 8 edges. The Hopcroft and Tarjan algorithm will attempt to traverse the graph using DFS, checking whether it can be embedded in the plane without crossing edges. If the embedding is successful, the graph is planar; otherwise, the algorithm will detect a non-planar structure.

Planarity Testing Hopcroft

The above graph contains back edges, indicating it is non-planar.

The Boykov-Kolmogorov Algorithm

The Boykov-Kolmogorov algorithm uses the max-flow min-cut method and is particularly useful for planarity testing in combinatorial optimization problems.

The max-flow min-cut theorem states that in a flow network, the maximum amount of flow that can be sent from a source to a sink is equal to the total weight of the smallest cut that separates the source and sink.

Although the Hopcroft and Tarjan algorithm is more commonly used for general graph planarity testing, the Boykov-Kolmogorov approach is suitable for specific cases where maximum flow problems are involved.

The major idea is to treat the graph as a flow network and apply the max-flow min-cut theorem to determine if a planar embedding is possible. One of the major advantages of this algorithm is its efficiency in handling dense graphs and large-scale network problems.

Using Kuratowski's Theorem

As mentioned earlier, Kuratowski's Theorem states that a graph is planar if and only if it does not contain a subgraph that is a subdivision of K5 or K3,3.

While this theorem provides a solid theoretical foundation for planarity testing, it is less efficient than algorithms like Hopcroft and Tarjan's, as identifying these subgraphs can be computationally expensive.

Nevertheless, there are algorithms based on this theorem that can detect non-planarity by identifying these subgraphs. The general steps involved are −

  • Step 1: Search the graph for any subgraphs that resemble K5 or K3,3.
  • Step 2: If such a subgraph is found, the graph is declared non-planar.
  • Step 3: If no such subgraph is found, the graph is potentially planar, but additional checks may be needed.

Applications of Planarity Testing Algorithms

Planarity testing algorithms are used in several areas of research and practical fields, such as −

  • Circuit Design: Planar graphs are used to design integrated circuits where wires must be laid out without crossing.
  • Graph Drawing: In graphical user interface (GUI) applications and visualization tools, planarity testing helps draw graphs in a way that minimizes edge crossings.
  • Geographical Mapping: Planarity testing is useful for representing maps and regions in a way that avoids overlapping edges between borders or regions.

Complexity of Planarity Testing Algorithms

The complexity of planarity testing algorithms is an important factor when choosing the most suitable method for a particular application −

  • Hopcroft and Tarjan Algorithm: This algorithm operates in linear time, O(n), where n is the number of vertices. This makes it suitable for large graphs.
  • Boykov-Kolmogorov Algorithm: The max-flow approach generally has higher computational complexity, especially for dense graphs. However, it is effective for specific scenarios involving network flow problems.
  • Kuratowski's Theorem-Based Approach: Algorithms based on this theorem can be computationally expensive, as they involve checking for subgraphs. The complexity depends on the size of the graph and the search technique used for identifying subgraphs.

Challenges in Planarity Testing

Although there are useful algorithms for planarity testing, it still presents several challenges −

  • Graph Size: The performance of planarity testing algorithms can degrade for large graphs, especially when using methods based on Kuratowski's Theorem.
  • Edge Density: Dense graphs with many edges may require more advanced techniques or approximations to test for planarity effectively.
  • Practical Limitations: Planarity testing algorithms are often designed for specific problem domains, and their efficiency can vary based on the graph type and application.
Advertisements