本文整理汇总了C++中GraphCopy::delNode方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphCopy::delNode方法的具体用法?C++ GraphCopy::delNode怎么用?C++ GraphCopy::delNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphCopy
的用法示例。
在下文中一共展示了GraphCopy::delNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clusterConnection
//todo: is called only once, but could be sped up the same way as the co-conn check
void MaxCPlanarMaster::clusterConnection(cluster c, GraphCopy &gc, double &upperBoundC) {
// For better performance, a node array is used to indicate which nodes are contained
// in the currently considered cluster.
NodeArray<bool> vInC(gc,false);
// First check, if the current cluster \a c is a leaf cluster.
// If so, compute the number of edges that have at least to be added
// to make the cluster induced graph connected.
if (c->cCount()==0) { //cluster \a c is a leaf cluster
GraphCopy *inducedC = new GraphCopy((const Graph&)gc);
List<node> clusterNodes;
c->getClusterNodes(clusterNodes); // \a clusterNodes now contains all (original) nodes of cluster \a c.
for (node w : clusterNodes) {
vInC[gc.copy(w)] = true;
}
// Delete all nodes from \a inducedC that do not belong to the cluster,
// in order to obtain the cluster induced graph.
node v = inducedC->firstNode();
while (v!=nullptr) {
node w = v->succ();
if (!vInC[inducedC->original(v)]) inducedC->delNode(v);
v = w;
}
// Determine number of connected components of cluster induced graph.
//Todo: check could be skipped
if (!isConnected(*inducedC)) {
NodeArray<int> conC(*inducedC);
int nCC = connectedComponents(*inducedC,conC);
//at least #connected components - 1 edges have to be added.
upperBoundC -= (nCC-1)*m_largestConnectionCoeff;
}
delete inducedC;
// Cluster \a c is an "inner" cluster. Process all child clusters first.
} else { //c->cCount is != 0, process all child clusters first
for (cluster ci : c->children) {
clusterConnection(ci, gc, upperBoundC);
}
// Create cluster induced graph.
GraphCopy *inducedC = new GraphCopy((const Graph&)gc);
List<node> clusterNodes;
c->getClusterNodes(clusterNodes); //\a clusterNodes now contains all (original) nodes of cluster \a c.
for (node w : clusterNodes) {
vInC[gc.copy(w)] = true;
}
node v = inducedC->firstNode();
while (v!=nullptr) {
node w = v->succ();
if (!vInC[inducedC->original(v)]) inducedC->delNode(v);
v = w;
}
// Now collapse each child cluster to one node and determine #connected components of \a inducedC.
List<node> oChildClusterNodes;
List<node> cChildClusterNodes;
for (cluster ci : c->children) {
ci->getClusterNodes(oChildClusterNodes);
// Compute corresponding nodes of graph \a inducedC.
for (node u : oChildClusterNodes) {
node copy = inducedC->copy(gc.copy(u));
cChildClusterNodes.pushBack(copy);
}
inducedC->collapse(cChildClusterNodes);
oChildClusterNodes.clear();
cChildClusterNodes.clear();
}
// Now, check \a inducedC for connectivity.
if (!isConnected(*inducedC)) {
NodeArray<int> conC(*inducedC);
int nCC = connectedComponents(*inducedC,conC);
//at least #connected components - 1 edges have to added.
upperBoundC -= (nCC-1)*m_largestConnectionCoeff;
}
delete inducedC;
}
}//clusterConnection