int main() { Graph G; GraphAttributes GA(G, GraphAttributes::nodeGraphics | GraphAttributes::edgeGraphics | GraphAttributes::nodeLabel | GraphAttributes::edgeStyle | GraphAttributes::nodeStyle | GraphAttributes::nodeTemplate); GraphIO::readGML(GA, G, "ERDiagram.gml"); PlanarizationLayout pl; SubgraphPlanarizer *crossMin = new SubgraphPlanarizer; FastPlanarSubgraph *ps = new FastPlanarSubgraph; ps->runs(100); VariableEmbeddingInserter *ves = new VariableEmbeddingInserter; ves->removeReinsert(rrAll); crossMin->setSubgraph(ps); crossMin->setInserter(ves); EmbedderMinDepthMaxFaceLayers *emb = new EmbedderMinDepthMaxFaceLayers; pl.setEmbedder(emb); OrthoLayout *ol = new OrthoLayout; ol->separation(20.0); ol->cOverhang(0.4); pl.setPlanarLayouter(ol); pl.call(GA); GraphIO::writeGML(GA, "ERDiagram-layout.gml"); return 0; }
int ERLayoutAlgorithm(Graph& G, GraphAttributes& GA) { PlanarizationGridLayout pl; SubgraphPlanarizer *crossMin = new SubgraphPlanarizer; // Get a planar subgraph using Boyer Myrvold Algorithm PlanarSubgraphBoyerMyrvold *ps = new PlanarSubgraphBoyerMyrvold; VariableEmbeddingInserter *ves = new VariableEmbeddingInserter; crossMin->setSubgraph(ps); crossMin->setInserter(ves); MixedModelLayout *ol = new MixedModelLayout; MMCBLocalStretch *cb = new MMCBLocalStretch; //ol->separation(180.0); ol->setCrossingsBeautifier(cb); pl.setPlanarLayouter(ol); pl.call(GA); return pl.numberOfCrossings(); }
//************************************************************* // call for SubgraphPlanarizer // returns crossing number int SimDrawCaller::callSubgraphPlanarizer(int cc, int numberOfPermutations) { // transfer edge costs if existent EdgeArray<int> ec(*m_G, 1); if(m_GA->attributes() & GraphAttributes::edgeIntWeight) { edge e; forall_edges(e,*m_G) ec[e] = m_GA->intWeight(e); } // initialize updateESG(); int crossNum = 0; PlanRep PR(*m_G); // actual call for connected component cc SubgraphPlanarizer SP; VariableEmbeddingInserter* vei = new VariableEmbeddingInserter; vei->removeReinsert(rrIncremental); SP.setInserter(vei); SP.permutations(numberOfPermutations); SP.call(PR, cc, crossNum, &ec, 0, m_esg); // insert all dummy nodes into original graph *m_G NodeArray<node> newOrigNode(PR); node vPR; forall_nodes(vPR, PR) { if(PR.isDummy(vPR)) { node vOrig = m_G->newNode(); newOrigNode[vPR] = vOrig; m_SD->isDummy(vOrig) = true; } else newOrigNode[vPR] = PR.original(vPR); //original nodes are saved } // insert all edges incident to dummy nodes into *m_G EdgeArray<bool> toBeDeleted(*m_G, false); EdgeArray<bool> visited(PR, false); forall_nodes(vPR, PR) { if(PR.isDummy(vPR)) { node vNewOrig = newOrigNode[vPR]; //lebt in *m_G edge e; forall_adj_edges(e, vPR) //lebt in PR { if(!visited[e]) { node w = e->opposite(vPR); //lebt in PR node wNewOrig = newOrigNode[w]; //lebt in *m_G edge eNewOrig = m_G->newEdge(vNewOrig,wNewOrig); m_GA->subGraphBits(eNewOrig) = m_GA->subGraphBits(PR.original(e)); toBeDeleted[PR.original(e)] = true; visited[e] = true; } } } }