Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz: how to insert two new linked nodes and minimize edge crossings?

I have the following graph graph:

As you can see, there are two natural clusters. I would like to figure out a way to separate these clusters into two graphs.

The key step, of course, is to compute the right split. I would like to insert two nodes n1 & n2, link them e(n1, n2), and move them around, minimizing the number of edge crossings (of course fixing all nodes/edges exactly where they are).

Can anyone offer any help here? I don't think graphviz has anything that enables me to do it.

like image 801
linhares Avatar asked Nov 03 '22 12:11

linhares


1 Answers

I think you mingle two different tasks here: the one is Analysis of a graph, the other one is Visualization of the same.

Graphviz, as the name suggests, is a tool for visualization of graphs. Visualization can take many forms, typically one tries to "make it look good" by having those nodes close to each other that are connected, thus reducing the visual edge lengths. One can utilize some spring- or gravitational model to calculate optimal positions for all nodes. Other options include circular- or shell-layouts.

A certain visualization should not be the basis for the analysis of a graph. Graph properties, like average shortest path length or clustering coefficient, are independent of any visualization.

You say you want to "minimize the number of edge crossings". The number of edge crossings is a property of your visualization, not of your graph! It probably changes each time you let graphviz calculate the layout, even if the graph is unchanged. Who says that 2d is the only possible representation of your graph? Add just one dimension, and you won't have any edge crossing.

I'd recommend to concentrate on graph analysis. I don't know if you're aware of NetworkX. They have dozens of Algorithms to analyze your graph. Maybe the clustering and clique sections are of interest to you.

like image 66
Thorsten Kranz Avatar answered Nov 08 '22 06:11

Thorsten Kranz