本文整理汇总了C++中TIntPrV::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntPrV::Len方法的具体用法?C++ TIntPrV::Len怎么用?C++ TIntPrV::Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntPrV
的用法示例。
在下文中一共展示了TIntPrV::Len方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLinkWgtDstEntIdPrVDiff
void TSkyGridBs::GetLinkWgtDstEntIdPrVDiff(
const TIntPrV& OldLinkWgtDstEntIdPrV, const TIntPrV& NewLinkWgtDstEntIdPrV,
TIntPrV& NegDiffLinkWgtDstEntIdPrV, TIntPrV& PosDiffLinkWgtDstEntIdPrV){
TIntIntH DstEntIdToLinkWgtH;
// set previous-vector
for (int WordN=0; WordN<NewLinkWgtDstEntIdPrV.Len(); WordN++){
int LinkWgt=NewLinkWgtDstEntIdPrV[WordN].Val1;
int DstEntId=NewLinkWgtDstEntIdPrV[WordN].Val2;
DstEntIdToLinkWgtH.AddDat(DstEntId, LinkWgt);
}
// diff current-vector
for (int WordN=0; WordN<OldLinkWgtDstEntIdPrV.Len(); WordN++){
int LinkWgt=OldLinkWgtDstEntIdPrV[WordN].Val1;
int DstEntId=OldLinkWgtDstEntIdPrV[WordN].Val2;
int CurLinkWgt=DstEntIdToLinkWgtH.AddDat(DstEntId);
DstEntIdToLinkWgtH.AddDat(DstEntId, CurLinkWgt-LinkWgt);
}
// extract vector
TIntPrV _DiffLinkWgtDstEntIdPrV;
DstEntIdToLinkWgtH.GetDatKeyPrV(_DiffLinkWgtDstEntIdPrV);
// clean zeros
TIntPrV DiffLinkWgtDstEntIdPrV(_DiffLinkWgtDstEntIdPrV.Len(), 0);
for (int EntN=0; EntN<_DiffLinkWgtDstEntIdPrV.Len(); EntN++){
int LinkWgt=_DiffLinkWgtDstEntIdPrV[EntN].Val1;
if (LinkWgt!=0){
DiffLinkWgtDstEntIdPrV.Add(_DiffLinkWgtDstEntIdPrV[EntN]);}
}
// positive-vector
DiffLinkWgtDstEntIdPrV.Sort(true);
NegDiffLinkWgtDstEntIdPrV=DiffLinkWgtDstEntIdPrV;
// negative-vector
DiffLinkWgtDstEntIdPrV.Sort(false);
PosDiffLinkWgtDstEntIdPrV=DiffLinkWgtDstEntIdPrV;
}
示例2: Get1CnCom
// get the node ids in 1-connected components
void Get1CnCom(const PUNGraph& Graph, TCnComV& Cn1ComV) {
//TCnCom::GetWccCnt(Graph, SzCntV); IAssertR(SzCntV.Len() == 1, "Graph is not connected.");
TIntPrV EdgeV;
GetEdgeBridges(Graph, EdgeV);
if (EdgeV.Empty()) { Cn1ComV.Clr(false); return; }
PUNGraph TmpG = TUNGraph::New();
*TmpG = *Graph;
for (int e = 0; e < EdgeV.Len(); e++) {
TmpG->DelEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
TCnComV CnComV; GetWccs(TmpG, CnComV);
IAssert(CnComV.Len() >= 2);
const TIntV& MxWcc = CnComV[0].NIdV;
TIntSet MxCcSet(MxWcc.Len());
for (int i = 0; i < MxWcc.Len(); i++) {
MxCcSet.AddKey(MxWcc[i]); }
// create new graph: bridges not touching MxCc of G with no bridges
for (int e = 0; e < EdgeV.Len(); e++) {
if (! MxCcSet.IsKey(EdgeV[e].Val1) && ! MxCcSet.IsKey(EdgeV[e].Val2)) {
TmpG->AddEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
}
GetWccs(TmpG, Cn1ComV);
// remove the largest component of G
for (int c = 0; c < Cn1ComV.Len(); c++) {
if (MxCcSet.IsKey(Cn1ComV[c].NIdV[0])) {
Cn1ComV.Del(c); break; }
}
}
示例3: GetSorted_LinkWgtDstEntIdPrV
void TSkyGridEnt::GetSorted_LinkWgtDstEntIdPrV(
const uint64& MnTm, const double& TopWgtSumPrc, TIntPrV& LinkWgtDstEntIdPrV) const {
double AllLinkWgtSum=0;
TIntIntH DstEntIdLinkWgtH;
int LinkEnts=GetLinkEnts();
for (int LinkEntN=0; LinkEntN<LinkEnts; LinkEntN++){
int DstEntId=GetLinkEntId(LinkEntN);
int EntLinks=GetEntLinks(LinkEntN);
int EntLinkWgtSum=0;
for (int EntLinkN=0; EntLinkN<EntLinks; EntLinkN++){
const TSkyGridEntLinkCtx& EntLinkCtx=GetEntLinkCtx(LinkEntN, EntLinkN);
if (EntLinkCtx.Tm>=MnTm){
EntLinkWgtSum+=EntLinkCtx.LinkWgt;}
}
DstEntIdLinkWgtH.AddDat(DstEntId, EntLinkWgtSum);
AllLinkWgtSum+=EntLinkWgtSum;
}
LinkWgtDstEntIdPrV.Clr(); DstEntIdLinkWgtH.GetDatKeyPrV(LinkWgtDstEntIdPrV);
LinkWgtDstEntIdPrV.Sort(false);
// cut long-tail
if ((TopWgtSumPrc>0.0)&&(LinkWgtDstEntIdPrV.Len()>0)){
int TopLinkWgt=LinkWgtDstEntIdPrV[0].Val1;
if (TopLinkWgt>(3*AllLinkWgtSum)/LinkWgtDstEntIdPrV.Len()){
double CutWgtSum=AllLinkWgtSum*(1-TopWgtSumPrc);
int LastValN=LinkWgtDstEntIdPrV.Len()-1;
while ((LastValN>0)&&(CutWgtSum>0)){
CutWgtSum-=LinkWgtDstEntIdPrV[LastValN].Val1;
LastValN--;
}
LinkWgtDstEntIdPrV.Trunc(LastValN+1);
}
}
}
示例4: AddPlot
int TGnuPlot::AddPlot(const TIntPrV& XYValV, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
TFltKdV XYFltValV(XYValV.Len(), 0);
for (int i = 0; i < XYValV.Len(); i++) {
XYFltValV.Add(TFltKd(TFlt(XYValV[i].Val1), TFlt(XYValV[i].Val2)));
}
return AddPlot(XYFltValV, SeriesTy, Label, Style);
}
示例5: ceil
bool TRf24Radio::Set(const uint16& NodeId, const TIntPrV& ValIdValPrV) {
Notify->OnNotifyFmt(TNotifyType::ntInfo, "Calling multiple SET for node %d ...", NodeId);
bool Success = true;
const int NMsgs = ceil(double(ValIdValPrV.Len()) / double(VALS_PER_PAYLOAD));
int RemainN = ValIdValPrV.Len();
for (int MsgN = 0; MsgN < NMsgs; MsgN++) {
const int PayloadSize = TMath::Mn(RemainN, VALS_PER_PAYLOAD);
TVec<TRadioValue> ValV(PayloadSize);
for (int ValN = 0; ValN < PayloadSize; ValN++) {
const TIntPr& ValIdValPr = ValIdValPrV[MsgN*VALS_PER_PAYLOAD + ValN];
TRadioValue& RadioVal = ValV[ValN];
RadioVal.SetValId((char) ValIdValPr.Val1);
RadioVal.SetVal(ValIdValPr.Val2);
}
TMem Payload; TRadioProtocol::GenSetPayload(ValV, Payload);
Success &= Send(NodeId, REQUEST_SET, Payload);
RemainN -= VALS_PER_PAYLOAD;
}
return Success;
}
示例6: TakeStat
void TakeStat(const PGraph& InfG, const PGraph& NetG, const TIntH& NIdInfTmH, const double& P, const bool& DivByM=true) {
const double M = DivByM ? InfG->GetNodes() : 1; IAssert(M>=1);
PGraph CcInf, CcNet; // largest connected component
// connected components and sizes
{ TCnComV CnComV; TSnap::GetWccs(InfG, CnComV);
NCascInf.AddDat(P).Add(CnComV.Len()/M);
MxSzInf.AddDat(P).Add(CnComV[0].Len()/M);
{ int a=0; for (int i=0; i<CnComV.Len(); i++) { a+=CnComV[i].Len(); }
AvgSzInf.AddDat(P).Add(a/double(CnComV.Len()*M)); }
CcInf = TSnap::GetSubGraph(InfG, CnComV[0].NIdV);
TSnap::GetWccs(NetG, CnComV);
NCascNet.AddDat(P).Add(CnComV.Len()/M);
MxSzNet.AddDat(P).Add(CnComV[0].Len()/M);
{ int a=0; for (int i=0; i<CnComV.Len(); i++) { a+=CnComV[i].Len(); }
AvgSzNet.AddDat(P).Add(a/double(CnComV.Len()*M)); }
CcNet = TSnap::GetSubGraph(NetG, CnComV[0].NIdV); }
// count isolated nodes and leaves; average in- and out-degree (skip leaves)
{ int i1=0, i2=0,l1=0,l2=0,r1=0,r2=0,ENet=0,EInf=0; double ci1=0,ci2=0,co1=0,co2=0;
for (typename PGraph::TObj::TNodeI NI = InfG->BegNI(); NI < InfG->EndNI(); NI++) {
if (NI.GetOutDeg()==0 && NI.GetInDeg()>0) { l1++; }
if (NI.GetOutDeg()>0 && NI.GetInDeg()==0) { r1++; }
if (NI.GetDeg()==0) { i1++; } if (NI.GetInDeg()>0) { ci1+=1; }
if (NI.GetOutDeg()>0) { co1+=1; } EInf+=NI.GetOutDeg(); }
for (typename PGraph::TObj::TNodeI NI = NetG->BegNI(); NI < NetG->EndNI(); NI++) {
if (NI.GetOutDeg()==0 && NI.GetInDeg()>0) { l2++; }
if (NI.GetOutDeg()>0 && NI.GetInDeg()==0) { r2++; }
if (NI.GetDeg()==0) { i2++; } if (NI.GetInDeg()>0) { ci2+=1; }
if (NI.GetOutDeg()>0) { co2+=1; } ENet+=NI.GetOutDeg(); }
if(ci1>0)InDegInf.AddDat(P).Add(EInf/ci1); if(ci2>0)InDegNet.AddDat(P).Add(ENet/ci2);
if(co1>0)OutDegInf.AddDat(P).Add(EInf/co1); if(co2>0)OutDegNet.AddDat(P).Add(ENet/co2);
NLfInf.AddDat(P).Add(l1/M); NLfNet.AddDat(P).Add(l2/M);
NRtInf.AddDat(P).Add(r1/M); NRtNet.AddDat(P).Add(r2/M);
NIsoInf.AddDat(P).Add(i1/M); NIsoNet.AddDat(P).Add(i2/M); }
// cascade depth
{ const double M1 = DivByM ? CcNet->GetNodes() : 1; IAssert(M1>=1);
int Root=FindCascadeRoot(CcInf, NIdInfTmH); TIntPrV HopCntV;
TSnap::GetNodesAtHops(CcInf, Root, HopCntV, true);
int MxN=0, Lev=0, IncL=0;
for (int i = 0; i < HopCntV.Len(); i++) {
if (MxN<HopCntV[i].Val2) { MxN=HopCntV[i].Val2; Lev=HopCntV[i].Val1; }
if (i > 0 && HopCntV[i-1].Val2<=HopCntV[i].Val2) { IncL++; } }
double D=0; int c=0; TIntH DistH;
D = HopCntV.Last().Val1; c=1; // maximum depth
if (c!=0 && D!=0) { D = D/c;
DepthInf.AddDat(P).Add(D/M1); MxWidInf.AddDat(P).Add(MxN/M1);
MxLevInf.AddDat(P).Add(Lev/D); IncLevInf.AddDat(P).Add(IncL/D);
}
Root=FindCascadeRoot(CcNet, NIdInfTmH);
TSnap::GetNodesAtHops(CcNet, Root, HopCntV, true);
MxN=0; Lev=0; IncL=0; D=0; c=0;
for (int i = 0; i < HopCntV.Len(); i++) {
if (MxN<HopCntV[i].Val2) { MxN=HopCntV[i].Val2; Lev=HopCntV[i].Val1; }
if (i > 0 && HopCntV[i-1].Val2<=HopCntV[i].Val2) { IncL++; } }
D = HopCntV.Last().Val1; c=1; // maximum depth
if (c!=0 && D!=0) { D = D/c;
DepthNet.AddDat(P).Add(D/M1); MxWidNet.AddDat(P).Add(MxN/M1);
MxLevNet.AddDat(P).Add(Lev/D); IncLevNet.AddDat(P).Add(IncL/D); }
}
}
示例7: SetLangCntryByMajority
// set Language and Country for movies that do not have the value set
// for every movie find the mojority language/country in 1-hop neighborhood and set it
void TImdbNet::SetLangCntryByMajority() {
// set language
while (true) {
TIntPrV NIdToVal;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (NI().GetLang() != 0) { continue; }
int Nbhs=0; TIntH LangCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
LangCntH.AddDat(NI.GetOutNDat(e).GetLang()) += 1; Nbhs++; }
for (int e = 0; e < NI.GetInDeg(); e++) {
LangCntH.AddDat(NI.GetInNDat(e).GetLang()) += 1; Nbhs++; }
if (LangCntH.IsKey(0)) { Nbhs-=LangCntH.GetDat(0); LangCntH.GetDat(0)=0; }
LangCntH.SortByDat(false);
if (LangCntH.GetKey(0) == 0) { continue; }
if (LangCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), LangCntH.GetKey(0))); }
}
if (NIdToVal.Empty()) { break; } // done
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Lang = NIdToVal[i].Val2; }
printf(" language set: %d\n", NIdToVal.Len());
}
int cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().GetLang()==0) cnt++; }
printf(" NO language: %d\n\n", cnt);
// set country
while (true) {
TIntPrV NIdToVal;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (NI().GetCntry() != 0) { continue; }
int Nbhs=0; TIntH CntryCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
CntryCntH.AddDat(NI.GetOutNDat(e).GetCntry()) += 1; Nbhs++; }
for (int e = 0; e < NI.GetInDeg(); e++) {
CntryCntH.AddDat(NI.GetInNDat(e).GetCntry()) += 1; Nbhs++; }
if (CntryCntH.IsKey(0)) { Nbhs-=CntryCntH.GetDat(0); CntryCntH.GetDat(0)=0; }
CntryCntH.SortByDat(false);
if (CntryCntH.GetKey(0) == 0) { continue; }
if (CntryCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), CntryCntH.GetKey(0))); }
}
if (NIdToVal.Empty()) { break; } // done
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Cntry = NIdToVal[i].Val2; }
printf(" country set: %d\n", NIdToVal.Len());
}
cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().GetCntry()==0) cnt++; }
printf(" NO country: %d\n\n", cnt);
}
示例8: SetActorCntryLangByMajority
// set actor's language and country
void TImdbNet::SetActorCntryLangByMajority() {
// set language
TIntPrV NIdToVal;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (! NI().IsActor()) { continue; }
IAssert(NI().GetLang() == 0); // no language set
IAssert(NI.GetInDeg() == 0); // actors point to movies
int Nbhs=0; TIntH LangCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
LangCntH.AddDat(NI.GetOutNDat(e).GetLang()) += 1; Nbhs++; }
if (LangCntH.IsKey(0)) { Nbhs-=LangCntH.GetDat(0); LangCntH.GetDat(0)=0; }
LangCntH.SortByDat(false);
if (LangCntH.GetKey(0) == 0) { continue; }
if (LangCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), LangCntH.GetKey(0))); }
}
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Lang = NIdToVal[i].Val2; }
printf(" language set: %d\n", NIdToVal.Len());
int cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetLang()==0) cnt++; }
printf(" Actors NO language: %d\n\n", cnt);
// set country
NIdToVal.Clr(true);
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
if (! NI().IsActor()) { continue; }
IAssert(NI().GetCntry() == 0); // no country set
IAssert(NI.GetInDeg() == 0); // actors point to movies
int Nbhs=0; TIntH CntryCntH;
for (int e = 0; e < NI.GetOutDeg(); e++) {
CntryCntH.AddDat(NI.GetOutNDat(e).GetCntry()) += 1; Nbhs++; }
if (CntryCntH.IsKey(0)) { Nbhs-=CntryCntH.GetDat(0); CntryCntH.GetDat(0)=0; }
CntryCntH.SortByDat(false);
if (CntryCntH.GetKey(0) == 0) { continue; }
if (CntryCntH[0]*2 >= Nbhs) {
NIdToVal.Add(TIntPr(NI.GetId(), CntryCntH.GetKey(0))); }
}
for (int i = 0; i < NIdToVal.Len(); i++) {
GetNDat(NIdToVal[i].Val1).Cntry = NIdToVal[i].Val2; }
printf(" country set: %d\n", NIdToVal.Len());
cnt=0;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { if (NI().IsActor() && NI().GetCntry()==0) cnt++; }
printf(" Actors NO country: %d\n\n", cnt);
}
示例9: GetLinkWgtDstEntIdPrVChA
void TSkyGridBs::GetLinkWgtDstEntIdPrVChA(
const TIntPrV& LinkWgtDstEntIdPrV, TChA& LinkWgtDstEntIdPrVChA){
LinkWgtDstEntIdPrVChA.Clr();
for (int DstEntN=0; DstEntN<LinkWgtDstEntIdPrV.Len(); DstEntN++){
int DstEntId=LinkWgtDstEntIdPrV[DstEntN].Val2;
TStr DstEntNm=GetEntNm(DstEntId);
int LinkWgt=LinkWgtDstEntIdPrV[DstEntN].Val1;
if (DstEntN>0){LinkWgtDstEntIdPrVChA+=' ';}
LinkWgtDstEntIdPrVChA+=TStr::Fmt("['%s':%d]", DstEntNm.CStr(), LinkWgt);
}
}
示例10: _SaveTaxonomyTxt
void TCycBs::_SaveTaxonomyTxt(FILE* fOut,
const int& Lev, TIntPrV& RelIdVIdPrV, TIntIntH& VIdToLevH){
for (int VidN=0; VidN<RelIdVIdPrV.Len(); VidN++){
int FromRelId=RelIdVIdPrV[VidN].Val1;
int SrcVId=RelIdVIdPrV[VidN].Val2;
TStr SrcVNm=GetVNm(SrcVId);
TCycVrtx& SrcVrtx=GetVrtx(SrcVId);
if (!SrcVrtx.IsFlag(cvfHumanOk)){continue;}
TStr FlagStr=SrcVrtx.GetFlagStr();
if (FromRelId==-1){
if (Lev>0){fprintf(fOut, "===upper");} else {fprintf(fOut, "===lower");}
fprintf(fOut, "=======================================================\n");
fprintf(fOut, "%s - %s\n", SrcVNm.CStr(), FlagStr.CStr());
} else {
TStr FromRelNm=GetVNm(FromRelId);
fprintf(fOut, "%*c[%s] --> %s\n", (Lev-1)*5, ' ', FromRelNm.CStr(), SrcVNm.CStr());
}
TIntPrV UpRelIdVIdPrV;
for (int EdgeN=0; EdgeN<SrcVrtx.GetEdges(); EdgeN++){
TCycEdge& Edge=SrcVrtx.GetEdge(EdgeN);
int RelId=Edge.GetRelId();
int DstVId=Edge.GetDstVId();
TStr RelNm=GetVNm(RelId);
TStr DstVNm=GetVNm(DstVId);
if (Lev>0){
// upper taxonomy
if ((RelNm=="#$isa")||(RelNm=="#$genls")){
if (!VIdToLevH.IsKey(DstVId)){
VIdToLevH.AddDat(DstVId, Lev+1);
UpRelIdVIdPrV.Add(TIntPr(RelId, DstVId));
}
}
} else {
// lower taxonomy
if ((RelNm=="~#$isa")||(RelNm=="~#$genls")){
if (!VIdToLevH.IsKey(DstVId)){
VIdToLevH.AddDat(DstVId, Lev-1);
UpRelIdVIdPrV.Add(TIntPr(RelId, DstVId));
}
}
}
}
// recursive call
if (Lev>0){
_SaveTaxonomyTxt(fOut, Lev+1, UpRelIdVIdPrV, VIdToLevH);
} else {
_SaveTaxonomyTxt(fOut, Lev-1, UpRelIdVIdPrV, VIdToLevH);
}
}
}
示例11: AddBiDirEdges
// Wgt == -1 : take the weight of the edge in the opposite direction
void TWgtNet::AddBiDirEdges(const double& Wgt) {
TIntPrV EdgeV;
for (TNodeI NI = BegNI(); NI < EndNI(); NI++) {
for (int e = 0; e < NI.GetOutDeg(); e++) {
if (! IsEdge(NI.GetOutNId(e), NI.GetId())) {
EdgeV.Add(TIntPr(NI.GetOutNId(e), NI.GetId())); }
}
}
for (int e = 0; e < EdgeV.Len(); e++) {
if (Wgt != -1) {
AddEdge(EdgeV[e].Val1, EdgeV[e].Val2, Wgt);
} else { // edge weight in the opposite direction
AddEdge(EdgeV[e].Val1, EdgeV[e].Val2, GetEDat(EdgeV[e].Val2, EdgeV[e].Val1));
}
}
}
示例12: AddSpuriousEdges
// network cascade: add spurious edges
// for more details see "Correcting for Missing Data in Information Cascades" by E. Sadikov, M. Medina, J. Leskovec, H. Garcia-Molina. WSDM, 2011
PNGraph AddSpuriousEdges(const PUNGraph& Graph, const PNGraph& Casc, TIntH NIdTmH) {
TIntPrV EdgeV;
for (TNGraph::TNodeI NI = Casc->BegNI(); NI < Casc->EndNI(); NI++) {
TUNGraph::TNodeI GNI = Graph->GetNI(NI.GetId());
const int Tm = NIdTmH.GetDat(NI.GetId());
for (int i=0,j=0; i < GNI.GetOutDeg(); i++) {
const int Dst = GNI.GetOutNId(i);
if (NIdTmH.IsKey(Dst) && Tm<NIdTmH.GetDat(Dst) && ! NI.IsNbhNId(Dst)) {
EdgeV.Add(TIntPr(GNI.GetId(), Dst)); }
}
}
PNGraph NetCasc = TNGraph::New();
*NetCasc = *Casc;
for (int e = 0; e < EdgeV.Len(); e++) {
NetCasc->AddEdge(EdgeV[e].Val1, EdgeV[e].Val2); }
return NetCasc;
}
示例13: GetMaxMinDeg
int GetMaxMinDeg(const PNGraph& G, const TStr& IsDir, const TStr& IsIn, const TStr& IsMax){
TIntPrV DegCnt;
if (IsDir == "false"){
PUNGraph U = TSnap::ConvertGraph<PUNGraph>(G);
if (IsIn == "true")
TSnap::GetInDegCnt(U, DegCnt);
else
TSnap::GetOutDegCnt(U, DegCnt);
}
else{
if (IsIn == "true")
TSnap::GetInDegCnt(G, DegCnt);
else
TSnap::GetOutDegCnt(G, DegCnt);
}
// sort in descending order
DegCnt.Sort(false);
if (IsMax == "true") return DegCnt[0].Val1;
else return DegCnt[DegCnt.Len()-1].Val1;
}
示例14: GetPdf
void TGUtil::GetPdf(const TIntPrV& CdfV, TIntPrV& PdfV) {
PdfV = CdfV;
for (int i = PdfV.Len()-1; i > 0; i--) {
PdfV[i].Val2 = PdfV[i].Val2 - PdfV[i-1].Val2; }
}
示例15: GetCCdf
void TGUtil::GetCCdf(const TIntPrV& PdfV, TIntPrV& CCdfV) {
CCdfV = PdfV;
for (int i = CCdfV.Len()-2; i >= 0; i--) {
CCdfV[i].Val2 = CCdfV[i+1].Val2 + CCdfV[i].Val2; }
}