本文整理汇总了C++中TIntPrV类的典型用法代码示例。如果您正苦于以下问题:C++ TIntPrV类的具体用法?C++ TIntPrV怎么用?C++ TIntPrV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIntPrV类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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; }
}
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:28,代码来源:cncom.cpp
示例2: Edge
void TSubGraphsEnum::RecurBfs1(const int& NId, const int& Depth) {
if (Depth == 0) {
TIntPrV EdgeV;
EdgeH.GetKeyV(EdgeV);
EdgeV.Sort();
SgV.Add(EdgeV);
return;
}
const TNGraph::TNodeI NI = NGraph ->GetNI(NId);
for (int e = 0; e < NI.GetOutDeg(); e++) {
const TIntPr Edge(NId, NI.GetOutNId(e));
if (! EdgeH.IsKey(Edge)) {
EdgeH.AddKey(Edge);
RecurBfs1(NI.GetOutNId(e), Depth-1);
EdgeH.DelKey(Edge);
}
}
for (int e = 0; e < NI.GetInDeg(); e++) {
const TIntPr Edge(NI.GetInNId(e), NId);
if (! EdgeH.IsKey(Edge)) {
EdgeH.AddKey(Edge);
RecurBfs1(NI.GetInNId(e), Depth-1);
EdgeH.DelKey(Edge);
}
}
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:26,代码来源:ghash.cpp
示例3: printf
TFfGGen::TStopReason TUndirFFire::AddNodes(const int& GraphNodes, const bool& FloodStop) {
printf("\n***Undirected GEO ForestFire: graph(%d,%d) add %d nodes, burn prob %.3f\n",
Graph->GetNodes(), Graph->GetEdges(), GraphNodes, BurnProb);
TExeTm ExeTm;
int Burned1 = 0, Burned2 = 0, Burned3 = 0; // last 3 fire sizes
TIntPrV NodesEdgesV;
// create initial set of nodes
if (Graph.Empty()) { Graph = PUNGraph::New(); }
if (Graph->GetNodes() == 0) { Graph->AddNode(); }
int NEdges = Graph->GetEdges();
// forest fire
for (int NNodes = Graph->GetNodes() + 1; NNodes <= GraphNodes; NNodes++) {
const int NewNId = Graph->AddNode(-1);
IAssert(NewNId == Graph->GetNodes() - 1); // node ids have to be 0...N
const int StartNId = Rnd.GetUniDevInt(NewNId);
const int NBurned = BurnGeoFire(StartNId);
// add edges to burned nodes
for (int e = 0; e < NBurned; e++) {
Graph->AddEdge(NewNId, GetBurnedNId(e));
}
NEdges += NBurned;
Burned1 = Burned2; Burned2 = Burned3; Burned3 = NBurned;
if (NNodes % Kilo(1) == 0) {
printf("(%d, %d) burned: [%d,%d,%d] [%s]\n", NNodes, NEdges, Burned1, Burned2, Burned3, ExeTm.GetStr());
NodesEdgesV.Add(TIntPr(NNodes, NEdges));
}
if (FloodStop && NEdges>1000 && NEdges / double(NNodes)>100.0) { // average node degree is more than 50
printf("!!! FLOOD. G(%6d, %6d)\n", NNodes, NEdges); return TFfGGen::srFlood;
}
}
printf("\n");
IAssert(Graph->GetEdges() == NEdges);
return TFfGGen::srOk;
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:34,代码来源:ff.cpp
示例4: DiffLinkWgtDstEntIdPrV
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;
}
开发者ID:Accio,项目名称:snap,代码行数:34,代码来源:skygrid.cpp
示例5: GetFqNmObjIdPrV
void TNmObjBs::GetFqNmObjIdPrV(
const TStr& TargetNmObjStr, TIntPrV& FqNmObjIdPrV) const {
//printf("Searching %s ...", TargetNmObjStr.CStr());
// get target named-object-id
int TargetNmObjId=GetNmObjId(TargetNmObjStr);
// collect target named-object frequencies
TIntIntH NmObjIdToFqH;
// traverse target named-object documents
int NmObjDocs=GetNmObjDocs(TargetNmObjId);
for (int NmObjDocIdN=0; NmObjDocIdN<NmObjDocs; NmObjDocIdN++){
// get document-id
int DocId=GetNmObjDocId(TargetNmObjId, NmObjDocIdN);
// traverse named-object in document
int DocNmObjs=GetDocNmObjs(DocId);
for (int DocNmObjN=0; DocNmObjN<DocNmObjs; DocNmObjN++){
// get named-object & frequency
int NmObjId; int TermFq;
GetDocNmObjId(DocId, DocNmObjN, NmObjId, TermFq);
// increment named-object document frequency
NmObjIdToFqH.AddDat(NmObjId)++;
}
}
// get & sort frequency table
FqNmObjIdPrV.Clr(); NmObjIdToFqH.GetDatKeyPrV(FqNmObjIdPrV);
FqNmObjIdPrV.Sort(false);
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:26,代码来源:nmobj.cpp
示例6: 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);
}
开发者ID:mkrnc,项目名称:snap,代码行数:7,代码来源:gnuplot.cpp
示例7: 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;
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:27,代码来源:rpi.cpp
示例8: 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); }
}
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:59,代码来源:cascades.cpp
示例9: GetSorted_DocsEntIdPrV
/////////////////////////////////////////////////
// SkyGrid-Base
void TSkyGridBs::GetSorted_DocsEntIdPrV(TIntPrV& DocsEntIdPrV){
TIntIntH EntIdToDocsH;
for (int EntId=0; EntId<GetEnts(); EntId++){
int Docs=GetEnt(EntId).GetDocIds();
EntIdToDocsH.AddDat(EntId, Docs);
}
DocsEntIdPrV.Clr(); EntIdToDocsH.GetDatKeyPrV(DocsEntIdPrV);
DocsEntIdPrV.Sort(false);
}
开发者ID:Accio,项目名称:snap,代码行数:11,代码来源:skygrid.cpp
示例10: GetAvgDepthFromRoot
double GetAvgDepthFromRoot(const PGraph& G) {
TMom Mom;
TIntPrV HopCntV;
for (typename PGraph::TObj::TNodeI NI = G->BegNI(); NI < G->EndNI(); NI++) {
if (NI.GetOutDeg()>0 && NI.GetInDeg()==0) {
TSnap::GetNodesAtHops(G, NI.GetId(), HopCntV, true);
Mom.Add(HopCntV.Last().Val1()); }
}
Mom.Def(); return Mom.GetMean();
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:10,代码来源:cascades.cpp
示例11: while
// 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);
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:52,代码来源:imdbnet.cpp
示例12: fprintf
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);
}
}
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:50,代码来源:cyc.cpp
示例13: InitItemSets
TIntPrV TTrawling::PlotMinFqVsMaxSet(const TStr& OutFNm) {
InitItemSets();
TIntPrV SzCntH;
SzCntH.Add(TIntPr(1, CurItemH.Len()));
for (int ItemSetSz = 2; ItemSetSz < 100; ItemSetSz++) {
printf("\nItemset size %d: ", ItemSetSz);
GetNextFqItemSets();
if (CurItemH.Empty()) { break; }
SzCntH.Add(TIntPr(ItemSetSz, CurItemH.Len()));
TGnuPlot::PlotValV(SzCntH, "itemSet-"+OutFNm, TStr::Fmt("Minimum Suport = %d", MinSup),
"Itemset size", "Number of itemsets > Minimum Support");
}
printf("\n\n");
return SzCntH;
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:15,代码来源:trawling.cpp
示例14: 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));
}
}
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:17,代码来源:wgtnet.cpp
示例15: 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;
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:19,代码来源:cascades.cpp
示例16: FOut
void TCycBs::SaveTaxonomyTxt(const TStr& FNm){
TFOut FOut(FNm); FILE* fOut=FOut.GetFileId();
for (int VId=0; VId<GetVIds(); VId++){
printf("%d/%d (%.1f%%)\r", 1+VId, GetVIds(), 100.0*(1+VId)/GetVIds());
//if (VId>10){break;}
// upper taxonomy
{int Lev=0;
TIntIntH VIdToLevH; VIdToLevH.AddDat(VId, Lev);
TIntPrV UpRelIdVIdPrV; UpRelIdVIdPrV.Add(TIntPr(-1, VId));
_SaveTaxonomyTxt(fOut, Lev+1, UpRelIdVIdPrV, VIdToLevH);}
// lower taxonomy
{int Lev=0;
TIntIntH VIdToLevH; VIdToLevH.AddDat(VId, Lev);
TIntPrV UpRelIdVIdPrV; UpRelIdVIdPrV.Add(TIntPr(-1, VId));
_SaveTaxonomyTxt(fOut, Lev-1, UpRelIdVIdPrV, VIdToLevH);}
}
printf("\n");
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:18,代码来源:cyc.cpp
示例17: TakeGraph
void TGraphKey::TakeGraph(const PNGraph& Graph, TIntPrV& NodeMap) {
TIntSet NodeIdH;
int n = 0;
NodeMap.Gen(Graph->GetNodes(), 0);
for (TNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++, n++) {
NodeIdH.AddKey(NI.GetId());
NodeMap.Add(TIntPr(NI.GetId(), n));
}
Nodes = Graph->GetNodes();
EdgeV.Gen(Nodes, 0);
for (TNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
const int NewNId = NodeIdH.GetKeyId(NI.GetId());
for (int i = 0; i < NI.GetOutDeg(); i++) {
EdgeV.Add(TIntPr(NewNId, NodeIdH.GetKeyId(NI.GetOutNId(i))));
}
}
EdgeV.Sort(true);
EdgeV.Pack();
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:19,代码来源:ghash.cpp
示例18: GetBiConSzCnt
void GetBiConSzCnt(const PUNGraph& Graph, TIntPrV& SzCntV) {
TCnComV BiCnComV;
GetBiCon(Graph, BiCnComV);
TIntH SzCntH;
for (int c =0; c < BiCnComV.Len(); c++) {
SzCntH.AddDat(BiCnComV[c].Len()) += 1;
}
SzCntH.GetKeyDatPrV(SzCntV);
SzCntV.Sort();
}
开发者ID:Aleyasen,项目名称:Alaki,代码行数:10,代码来源:cncom.cpp
示例19: GetNGramStrV
void TNGramBs::GetNGramStrV(
const TStr& HtmlStr, TStrV& NGramStrV, TIntPrV& NGramBEChXPrV) const {
TIntV NGramIdV; NGramStrV.Clr(); NGramBEChXPrV.Clr();
TNGramBs::GetNGramIdV(HtmlStr, NGramIdV, NGramBEChXPrV);
NGramStrV.Gen(NGramIdV.Len(), 0);
for (int NGramIdN=0; NGramIdN<NGramIdV.Len(); NGramIdN++){
TStr NGramStr=GetNGramStr(NGramIdV[NGramIdN]);
NGramStrV.Add(NGramStr);
}
}
开发者ID:bergloman,项目名称:qminer,代码行数:10,代码来源:phrase.cpp
示例20: TEST
// Test GetTriadParticip
// Number of nodes with x number of triangles it participates in
TEST(triad, TestGetTriadParticip) {
// Test TUNGraph
PUNGraph GraphTUN = TriadGetTestTUNGraph();
TIntPrV TriadCntV;
TSnap::GetTriadParticip(GraphTUN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
// Test TNGraph which is same as undirected.
PNGraph GraphTN = TriadGetTestTNGraph();
TriadCntV.Clr();
TSnap::GetTriadParticip(GraphTN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
// Test TNEGraph which is same as undirected.
PNEGraph GraphTNE = TriadGetTestTNEGraph();
TriadCntV.Clr();
TSnap::GetTriadParticip(GraphTN, TriadCntV);
VerifyGetTriadParticip(TriadCntV);
}
开发者ID:Antobiotics,项目名称:snap,代码行数:21,代码来源:test-triad.cpp
注:本文中的TIntPrV类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论