本文整理汇总了C++中TIntH::DelKey方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntH::DelKey方法的具体用法?C++ TIntH::DelKey怎么用?C++ TIntH::DelKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntH
的用法示例。
在下文中一共展示了TIntH::DelKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MaxCPGreedyBetter
// Maximum Domination Problem
void MaxCPGreedyBetter(const PUNGraph& Graph, const int k, TIntH& GroupNodes) {
// buildup cpntainer of group nodes
const int n = Graph->GetNodes();
int *NNodes = new int[n]; // container of neighbouring nodes
int NNodes_br = 0;
TIntH Nodes; // nodes sorted by vd
double gc = 0, gc0 = 0;
int addId = 0, addIdPrev = 0;
for (TUNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++){
Nodes.AddDat(NI.GetId(), NI.GetDeg());
}
Nodes.SortByDat(false);
int br = 0;
while (br < k) {
for (THashKeyDatI<TInt, TInt> NI = Nodes.BegI(); NI < Nodes.EndI(); NI++){
if ((NI.GetDat() <= (int)gc0))
break;
gc = NI.GetDat() - Intersect(Graph->GetNI(NI.GetKey()), NNodes, NNodes_br);
if (gc>gc0){
gc0 = gc;
addId = NI.GetKey();
}
}
if (addId != addIdPrev) {
GroupNodes.AddDat(br, addId);
br++;
gc0 = 0;
int nn = addId;
bool nnnew = true;
for (int j = 0; j<NNodes_br; j++)
if (NNodes[j] == nn){
nnnew = false;
j = NNodes_br;
}
if (nnnew){
NNodes[NNodes_br] = nn;
NNodes_br++;
}
for (int i = 0; i<Graph->GetNI(addId).GetDeg(); i++) {
int nn = Graph->GetNI(addId).GetNbrNId(i);
bool nnnew = true;
for (int j = 0; j<NNodes_br; j++) {
if (NNodes[j] == nn){
nnnew = false;
j = NNodes_br;
}
}
if (nnnew){
NNodes[NNodes_br] = nn;
NNodes_br++;
}
}
addIdPrev = addId;
Nodes.DelKey(addId);
}
else {
br = k;
}
printf("%i,", br);
}
delete NNodes;
}