//in ClusterGraph?? //is not yet recursive!!! node collapseCluster(ClusterGraph& CG, cluster c, Graph& G) { OGDF_ASSERT(c->cCount() == 0) ListIterator<node> its; SListPure<node> collaps; //we should check here if not empty node robinson = (*(c->nBegin())); for (its = c->nBegin(); its.valid(); its++) collaps.pushBack(*its); CG.collaps(collaps, G); if (c != CG.rootCluster()) CG.delCluster(c); return robinson; }
// Recursive call for testing c-planarity of the clustered graph // that is induced by cluster act bool CconnectClusterPlanar::planarityTest( ClusterGraph &C, cluster &act, Graph &G) { // Test children first ListConstIterator<cluster> it; for (it = act->cBegin(); it.valid();) { ListConstIterator<cluster> succ = it.succ(); cluster next = (*it); if (!planarityTest(C,next,G)) return false; it = succ; } // Get induced subgraph of cluster act and test it for planarity List<node> subGraphNodes; for (node s : act->nodes) subGraphNodes.pushBack(s); Graph subGraph; NodeArray<node> table; inducedSubGraph(G,subGraphNodes.begin(),subGraph,table); // Introduce super sink and add edges corresponding // to outgoing edges of the cluster node superSink = subGraph.newNode(); EdgeArray<node> outgoingTable(subGraph,nullptr); for (node w : act->nodes) { //adjEntry adj = w->firstAdj(); for(adjEntry adj : w->adjEntries) { edge e = adj->theEdge(); edge cor = nullptr; if (table[e->source()] == nullptr) // edge is connected to a node outside the cluster { cor = subGraph.newEdge(table[e->target()],superSink); outgoingTable[cor] = e->source(); } else if (table[e->target()] == nullptr) // dito { cor = subGraph.newEdge(table[e->source()],superSink); outgoingTable[cor] = e->target(); } // else edge connects two nodes of the cluster } } if (superSink->degree() == 0) // root cluster is not connected to outside clusters { subGraph.delNode(superSink); superSink = nullptr; } bool cPlanar = preparation(subGraph,act,superSink); if (cPlanar && act != C.rootCluster()) { // Remove induced subgraph and the cluster act. // Replace it by a wheel graph while (!subGraphNodes.empty()) { node w = subGraphNodes.popFrontRet(); // C.unassignNode(w); G.delNode(w); } cluster parent = act->parent(); if (superSink && m_clusterPQTree[act]) constructWheelGraph(C,G,parent,m_clusterPQTree[act],outgoingTable); C.delCluster(act); if (m_clusterPQTree[act] != nullptr) // if query necessary for clusters with just one child { m_clusterPQTree[act]->emptyAllPertinentNodes(); delete m_clusterPQTree[act]; } } else if (!cPlanar) { m_errorCode = nonCPlanar; }//if not cplanar return cPlanar; }