Cluster Ortho Layout segmentation fault

52 views
Skip to first unread message

Fede Pantos

unread,
Nov 17, 2020, 4:05:52 PM11/17/20
to ogdf
Hello everyone,

I'm currently working on a project that uses OGDF for clustering, planarization and drawing.

What I'm trying to implement right now is put a constraint on two nodes of being external on the layout.
I'll try to be more specific: I have graphs with 4,5,6 or 7 nodes most of the times.
They are created in a random way. I managed to create one internal cluster with parent cluster the root and I extracted two nodes by adding two additional nodes in the internal cluster and adding two new edges.
So I want to create another additional cluster, with parent the internal cluster, with the two extracted nodes and build a cluster planarization layout with it.
The problem is that when I call the algorithm, a segmentation fault error comes up on the  ClusterOrthoLayout call.
I wonder if anyone has some insights on what the problem could be.

Dagobert Smart

unread,
Nov 18, 2020, 6:33:20 AM11/18/20
to ogdf
Hello Fede,

I assume that this corresponds to the bug described in https://github.com/ogdf/ogdf/issues/45.
If your case is very different from that GitHub-issue, a minimal example to reproduce the problem or a stack trace would be very helpful.
Otherwise we are aware of the problem; however, the current OGDF developers are not very familiar with the cluster functionality and in general, fixing cluster-related algorithms is not a current priority.

Best regards,
Dagobert

Fede Pantos

unread,
Nov 18, 2020, 10:42:58 AM11/18/20
to ogdf
The segmentation fault error is similar but I don't build empty clusters, but maybe I am building them in a wrong way.
I leave the part of the code that gives problem below.
My main purpose is to create one cluster of internal nodes and another cluster of two external nodes of the same connected graph so that when I create a planarization layout, I force  the external nodes to be outer of the internal cluster in the layout.
I hope that it's clear.

     Graph G;
ClusterGraph CG(G);
ClusterGraphAttributes CGA(CG,
GraphAttributes::nodeGraphics | GraphAttributes::nodeType | GraphAttributes::nodeLabel | GraphAttributes::nodeStyle |
GraphAttributes::edgeGraphics | GraphAttributes::edgeType | GraphAttributes::edgeLabel);    
       //Graph is initialized by reading an external template.
       <string>LabelOfEdge= //initialized to a particular label.

<edge> ports;
pair<node, node> extracted;
cluster internalCluster;
ports = getEdgeByLabel(G, CGA, LabelOfEdge);
SList<node> intern;
G.allNodes(intern);
internalCluster = CG.createCluster(intern);
extracted = extractEdge(G, CGA, ports);
SList<node> extr;
extr.pushBack(extracted.first);
extr.pushBack(extracted.second);
CG.createCluster(extr, internalCluster);
extr.clear();

ClusterPlanarizationLayout cpl;
SubgraphPlanarizer crossMin;
auto* psf = new PlanarSubgraphFast<int>;
psf->runs(100);
VariableEmbeddingInserter *vei = new VariableEmbeddingInserter;
vei->removeReinsert(RemoveReinsertType::All);
crossMin.setSubgraph(psf);
crossMin.setInserter(vei);
ClusterOrthoLayout *col = new ClusterOrthoLayout;
col->separation(2);
col->cOverhang(0.4);
cpl.setPlanarLayouter(col);
cpl.call(G, CGA, CG, true);

Customized functions are in the next part of the comments (If you want to reproduce the problem)-->
ExtractEdge function:
pair<node, node> extractEdge(Graph& G, ClusterGraphAttributes& CGA, edge e)
{
pair<node, node> res(nullptr, nullptr);
if(e == nullptr) return res;
node n1 = G.newNode();
node n2 = G.newNode();
res = {n1, n2};
CGA.label(n1) = CGA.label(e) + ":0";
CGA.label(n2) = CGA.label(e) + ":1";
buildEdgeByNodes(G, CGA, e->source(), n1);
buildEdgeByNodes(G, CGA, n2, e->target());
G.moveSource(e, n1);
G.moveTarget(e, n2);
return res;
}

getEdgeByLabel function:
edge getEdgeByLabel(Graph& G, ClusterGraphAttributes& CGA, string label)
{
return G.chooseEdge([&](edge e){return CGA.label(e) == label;});
}
Reply all
Reply to author
Forward
0 new messages