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;});
}