Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimizing number of crossings in a bipartite graph

The following algorithm problem occurred to me while drawing a graph for something unrelated:

enter image description here

We have a plane drawing of a bipartite graph, with the disjoint sets arranged in columns as shown. How can we rearrange the nodes within each column so that the number of edge crossings is minimized? I know this problem is NP-hard for general graphs (link), but is there some trick considering that the graph is bipartite?

As a follow-up, what if there is a third column w, which only has edges to v? Or further?

like image 883
Imre Kerr Avatar asked Nov 20 '13 21:11

Imre Kerr


People also ask

How do you find the crossing number of a graph?

Definition: The crossing number of a graph G, denoted cr(G), is the minimum number of crossings in any simple drawing of G. ▶ So if G is planar, cr(G) = 0, and if G is non-planar, cr(G) ≥ 1. ▶ To prove cr(G) = 1: ▶ Prove G is non-planar (Kuratowski or otherwise) and ▶ Find a drawing of G with only one crossing.

What are crossing points on a graph?

Definitions. For the purposes of defining the crossing number, a drawing of an undirected graph is a mapping from the vertices of the graph to disjoint points in the plane, and from the edges of the graph to curves connecting their two endpoints.

What is the crossing number of K5?

K5 has crossing number 1.

What are the properties of bipartite graph?

A graph is bipartite if and only if it is 2-colorable, (i.e. its chromatic number is less than or equal to 2). A graph is bipartite if and only if every edge belongs to an odd number of bonds, minimal subsets of edges whose removal increases the number of components of the graph.


2 Answers

The paper On the one-sided crossing minimization in a bipartite graph with large degrees by Hiroshi Nagamochi mentions that the original paper on the crossing number by Garey and Johnson also proved that minimising the number of edge crossings is NP-hard for bipartite graphs. In fact, it is still NP-hard even if you are told the optimal order for one column:

Given a bipartite graph, a 2-layered drawing consists of placing nodes in the first node set V on a straight line L1 and placing nodes in the second node set W on a parallel line L2. The problem of minimizing the number of crossings between arcs in a 2-layered drawing was first introduced by Harary and Schwenk. The one-sided crossing minimization problem asks to find an ordering of nodes in V to be placed on L1 so that the number of arc crossings is minimized (while the ordering of the nodes in W on L2 is given and fixed). Applications of the problem can be found in VLSI layouts and hierarchical drawings.

However, the two-sided and one-sided problems are shown to be NP-hard by Garey and Johnson and by Eades and Wormald , respectively.

like image 130
Peter de Rivaz Avatar answered Oct 08 '22 13:10

Peter de Rivaz


Peter de Rivaz pointed that it is NP-Hard, but still if you are fine with some approximation you can go with the following solution.

My initial thought was to use some force-based algorithm for graph layouting, but it can be bit tedious to implement. But hey, there is this wonderful program graphviz.org, that can make the whole work for you.

So after installing just prepare a file with your graph:

graph G{
   {rank=same A B C D E}
   {rank=same F G H K I J}

    A -- F;
    A -- G;
    A -- K;
    A -- I;
    A -- H;
    A -- J;

    B -- G;

    C -- G;
    C -- J;

    D -- K;
    D -- I;
}

Run: dot -Tpng yourgraph -o yourgraph.png

and get something like that for free :-):

enter image description here

like image 37
artur grzesiak Avatar answered Oct 08 '22 13:10

artur grzesiak