Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph auto-layout algorithm

To simplify the problem, I have a graph that contains nodes and edges which are on a 2D plane.

What I want to be able to do is click a button and it make the automatically layout the graph to look clean. By that I mean minimal crossing of edges, nice space between nodes, maybe even represent the graph scale (weighted edges).

I know this is completely subjective of what is a clean looking graph, but does anyone know of an algorithm to start with, rather than reinventing the wheel?

Thanks.

like image 611
Cheetah Avatar asked Feb 17 '11 11:02

Cheetah


People also ask

What is graph layout algorithm?

A layout algorithm addresses one or more quality criteria, depending on the type of graph and the features of the algorithm, when laying out a graph. The most common criteria are: Minimizing the number of link crossings. Minimizing the total area of the drawing. Minimizing the number of bends (in orthogonal drawings)

Which algorithm is used in graph?

Floyd Warshall algorithm is a great algorithm for finding shortest distance between all vertices in graph. It has a very concise algorithm and O(V^3) time complexity (where V is number of vertices). It can be used with negative weights, although negative weight cycles must not be present in the graph.


2 Answers

You will find http://graphdrawing.org/ and this tutorial, by Roberto Tamassia, professor at Brown University, quite helpful.

I like a lot Force-Directed Techniques (pp. 66-72 in the tutorial) like the Spring Embedder.

You assume there is a spring or other force between any two adjacent nodes and let nature (simulation) do the work :)

like image 62
ypercubeᵀᴹ Avatar answered Sep 18 '22 19:09

ypercubeᵀᴹ


I would suggest that you take a look at at graphviz. The dot program can take a specification of a graph and generate an image of the network for you somewhat "cleanly". I've linked to the "theory" page that gives you some links that might be relevant if you're interested in the theoretical background. The library and tools themselves are mature enough if you simply want a solution to a problem with layout that you're facing.

like image 33
Noufal Ibrahim Avatar answered Sep 19 '22 19:09

Noufal Ibrahim