本文整理汇总了C++中TIntH::EndI方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntH::EndI方法的具体用法?C++ TIntH::EndI怎么用?C++ TIntH::EndI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntH
的用法示例。
在下文中一共展示了TIntH::EndI方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGroupDegreeCentr
double GetGroupDegreeCentr(const PUNGraph& Graph, const TIntH& GroupNodes) {
int deg;
TIntH NN;
TIntH GroupNodes1;
for (THashKeyDatI<TInt, TInt> NI = GroupNodes.BegI(); NI < GroupNodes.EndI(); NI++)
GroupNodes1.AddDat(NI.GetDat(), NI.GetDat());
for (THashKeyDatI<TInt, TInt> NI = GroupNodes1.BegI(); NI < GroupNodes1.EndI(); NI++){
TUNGraph::TNodeI node = Graph->GetNI(NI.GetKey());
deg = node.GetDeg();
for (int j = 0; j < deg; j++){
if (GroupNodes1.IsKey(node.GetNbrNId(j)) == 0 && NN.IsKey(node.GetNbrNId(j)) == 0)
NN.AddDat(node.GetNbrNId(j), NI.GetKey());
}
}
return (double)NN.Len();
}
示例2: 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;
}
示例3: GenCascade
void TNetInfBs::GenCascade(TCascade& C, const int& TModel, const double &window, TIntPrIntH& EdgesUsed, const double& delta,
const double& std_waiting_time, const double& std_beta) {
TIntFltH InfectedNIdH; TIntH InfectedBy;
double GlobalTime; int StartNId;
double alpha, beta;
if (GroundTruth->GetNodes() == 0)
return;
while (C.Len() < 2) {
C.Clr();
InfectedNIdH.Clr();
InfectedBy.Clr();
GlobalTime = 0;
StartNId = GroundTruth->GetRndNId();
InfectedNIdH.AddDat(StartNId) = GlobalTime;
while (true) {
// sort by time & get the oldest node that did not run infection
InfectedNIdH.SortByDat(true);
const int& NId = InfectedNIdH.BegI().GetKey();
GlobalTime = InfectedNIdH.BegI().GetDat();
// all the nodes has run infection
if (GlobalTime >= window)
break;
// add current oldest node to the network and set its time
C.Add(NId, GlobalTime);
// run infection from the current oldest node
const TNGraph::TNodeI NI = GroundTruth->GetNI(NId);
for (int e = 0; e < NI.GetOutDeg(); e++) {
const int DstNId = NI.GetOutNId(e);
beta = Betas.GetDat(TIntPr(NId, DstNId));
// flip biased coin (set by beta)
if (TInt::Rnd.GetUniDev() > beta+std_beta*TFlt::Rnd.GetNrmDev())
continue;
alpha = Alphas.GetDat(TIntPr(NId, DstNId));
// not infecting the parent
if (InfectedBy.IsKey(NId) && InfectedBy.GetDat(NId).Val == DstNId)
continue;
double sigmaT;
switch (TModel) {
case 0:
// exponential with alpha parameter
sigmaT = TInt::Rnd.GetExpDev(alpha);
break;
case 1:
// power-law with alpha parameter
sigmaT = TInt::Rnd.GetPowerDev(alpha);
while (sigmaT < delta) { sigmaT = TInt::Rnd.GetPowerDev(alpha); }
break;
case 2:
// rayleigh with alpha parameter
sigmaT = TInt::Rnd.GetRayleigh(1/sqrt(alpha));
break;
default:
sigmaT = 1;
break;
}
// avoid negative time diffs in case of noise
if (std_waiting_time > 0)
sigmaT = TFlt::GetMx(0.0, sigmaT + std_waiting_time*TFlt::Rnd.GetNrmDev());
double t1 = GlobalTime + sigmaT;
if (InfectedNIdH.IsKey(DstNId)) {
double t2 = InfectedNIdH.GetDat(DstNId);
if (t2 > t1 && t2 != window) {
InfectedNIdH.GetDat(DstNId) = t1;
InfectedBy.GetDat(DstNId) = NId;
}
} else {
InfectedNIdH.AddDat(DstNId) = t1;
InfectedBy.AddDat(DstNId) = NId;
}
}
// we cannot delete key (otherwise, we cannot sort), so we assign a big time (window cut-off)
InfectedNIdH.GetDat(NId) = window;
}
}
C.Sort();
for (TIntH::TIter EI = InfectedBy.BegI(); EI < InfectedBy.EndI(); EI++) {
TIntPr Edge(EI.GetDat().Val, EI.GetKey().Val);
if (!EdgesUsed.IsKey(Edge)) EdgesUsed.AddDat(Edge) = 0;
EdgesUsed.GetDat(Edge) += 1;
//.........这里部分代码省略.........