microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.36k stars 304 forks source link

[Question] Placement of isolated nodes #257

Open hybridherbst opened 4 years ago

hybridherbst commented 4 years ago

I'm using the AutomaticGraphLayout package to lay out ~200-300 nodes with varying edge counts between them (between 0 and 30).

Currently I'm using a SugiyamaLayout, but that seems to have issues with isolated nodes (some nodes just don't have any edges), kind of sometimes grouping them and sometimes scattering them around.

Is there

  1. a way to control placement of isolated nodes with SugiyamaLayout
  2. a better layout algorithm in this library for such a case
  3. a comparison page which layout is suited towards what kind of graph / data?

Thanks!

SMTStuck commented 4 years ago
  1. Do you mean calculating the subgraphs and positioning them? You can easily position the subgraphs wherever you fancy. You may have issues though with subgraphs of subgraphs. Rather than running the layout on the entire GeometryGraph you could call the GraphConnectedComponents.CreateComponents method which calculates the subgraphs and run the layout on each one:
IEnumerable<GeometryGraph> subGraphs = GraphConnectedComponents.CreateComponents(geometryGraph.Nodes, geometryGraph.Edges);

SugiyamaLayoutSettings layoutSettings = new SugiyamaLayoutSettings();
layoutSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Rectilinear;
layoutSettings.NodeSeparation = 120;
layoutSettings.LayerSeparation = 120;

foreach (GeometryGraph subgraph in subGraphs)
{
    LayeredLayout layout = new LayeredLayout(subgraph, layoutSettings);
    layout.Run();
}

After this you would be free to position each subgraph whever you fancied.

  1. The above may help.

  2. Haven't seen anything suggesting this.

hybridherbst commented 4 years ago

Thank you, that might help. I'll report back here once I get time to try it!