SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
00001 00002 // Graph Statistics 00003 // statistics of a single snapshot of a graph 00004 class TGStat; 00005 typedef TPt<TGStat> PGStat; 00006 typedef TVec<PGStat> TGStatV; 00007 00008 // statistics of a sequence of graph snapshots 00009 class TGStatVec; 00010 typedef TPt<TGStatVec> PGStatVec; 00011 00013 // Statistics of a Sigle Graph 00014 // Scalar statistics of the graph 00015 typedef enum { 00016 gsvNone, gsvTime, gsvNodes, gsvZeroNodes, gsvNonZNodes, gsvSrcNodes, gsvDstNodes, 00017 gsvEdges, gsvUniqEdges, gsvBiDirEdges, 00018 gsvWccNodes, gsvWccSrcNodes, gsvWccDstNodes, gsvWccEdges, gsvWccUniqEdges, gsvWccBiDirEdges, 00019 gsvFullDiam, gsvEffDiam, gsvEffWccDiam, gsvFullWccDiam, 00020 gsvFullDiamDev, gsvEffDiamDev, gsvEffWccDiamDev, gsvFullWccDiamDev, // diameter+variance 00021 gsvClustCf, gsvOpenTriads, gsvClosedTriads, gsvWccSize, 00022 gsvMx 00023 } TGStatVal; 00024 00025 // Distribution statistics of the graph 00026 typedef enum { 00027 gsdUndef=100, gsdInDeg, gsdOutDeg, gsdWcc, gsdScc, 00028 gsdHops, gsdWccHops, gsdSngVal, gsdSngVec, gsdClustCf, 00029 gsdTriadPart, // triad participation 00030 gsdMx, 00031 } TGStatDistr; 00032 00035 class TGStat { 00036 public: 00037 static int NDiamRuns; 00038 static int TakeSngVals; 00039 typedef TQuad<TStr, TStr, TStr, TGpScaleTy> TPlotInfo; // file prefix, x label, y label, scale 00040 public: 00041 class TCmpByVal { 00042 private: 00043 TGStatVal ValCmp; 00044 bool SortAsc; 00045 public: 00046 TCmpByVal(TGStatVal SortBy, bool Asc) : ValCmp(SortBy), SortAsc(Asc) { } 00047 bool operator () (const TGStat& GS1, const TGStat& GS2) const; 00048 bool operator () (const PGStat& GS1, const PGStat& GS2) const; 00049 }; 00050 private: 00051 const static TFltPrV EmptyV; 00052 TCRef CRef; 00053 public: 00054 TSecTm Time; 00055 TStr GraphNm; 00056 TIntFltH ValStatH; // scalar statistics 00057 THash<TInt, TFltPrV> DistrStatH; // distribution statistics 00058 public: 00059 TGStat(const TSecTm& GraphTm = TSecTm(), const TStr& GraphName=TStr()); 00060 TGStat(const PNGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), const TStr& GraphName=TStr()); 00061 TGStat(const PNEGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), const TStr& GraphName=TStr()); 00062 template <class PGraph> TGStat(const PGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), const TStr& GraphName=TStr()) { 00063 TakeStat(Graph, Time, StatFSet, GraphName); } 00064 TGStat(const TGStat& GStat); 00065 TGStat(TSIn& SIn); 00066 void Save(TSOut& SOut) const; 00067 static PGStat New(const TSecTm& Time=TSecTm(), const TStr& GraphName=TStr()) { 00068 return new TGStat(Time, GraphName); } 00069 static PGStat New(const PNGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), 00070 const TStr& GraphNm=TStr()) { return new TGStat(Graph, Time, StatFSet, GraphNm); } 00071 static PGStat New(const PNEGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), 00072 const TStr& GraphNm=TStr()) { return new TGStat(Graph, Time, StatFSet, GraphNm); } 00073 template <class PGraph> PGStat New(const PGraph& Graph, const TSecTm& Time, TFSet StatFSet=TFSet(), 00074 const TStr& GraphNm=TStr()) { return new TGStat(Graph, Time, StatFSet, GraphNm); } 00075 static PGStat Load(TSIn& SIn) { return new TGStat(SIn); } 00076 PGStat Clone() const { return new TGStat(*this); } 00077 TGStat& operator = (const TGStat& GStat); 00078 bool operator == (const TGStat& GStat) const; 00079 bool operator < (const TGStat& GStat) const; 00080 00081 int GetYear() const { return Time.GetYearN(); } 00082 int GetMonth() const { return Time.GetMonthN(); } 00083 int GetDay() const { return Time.GetDayN(); } 00084 int GetHour() const { return Time.GetHourN(); } 00085 int GetMin() const { return Time.GetMinN(); } 00086 int GetSec() const { return Time.GetSecN(); } 00087 TStr GetTmStr() const { return Time.GetStr(); } 00088 void SetTm(const TSecTm& GraphTm) { Time = GraphTm; } 00089 TStr GetNm() const { return GraphNm; } 00090 void SetNm(const TStr& GraphName) { GraphNm=GraphName; } 00091 00092 int GetVals() const { return ValStatH.Len(); } 00093 bool HasVal(const TGStatVal& StatVal) const; 00094 double GetVal(const TGStatVal& StatVal) const; 00095 void SetVal(const TGStatVal& StatVal, const double& Val); 00096 int GetDistrs() const { return DistrStatH.Len(); } 00097 bool HasDistr(const TGStatDistr& Distr) const { return DistrStatH.IsKey(Distr); } 00098 const TFltPrV& GetDistr(const TGStatDistr& Distr) const; 00099 void GetDistr(const TGStatDistr& Distr, TFltPrV& FltPrV) const; 00100 void SetDistr(const TGStatDistr& Distr, const TFltPrV& FltPrV); 00101 00102 int GetNodes() const { return (int) GetVal(gsvNodes); } 00103 int GetEdges() const { return (int) GetVal(gsvEdges); } 00104 00105 void TakeStat(const PNGraph& Graph, const TSecTm& Time, TFSet StatFSet, const TStr& GraphName); 00106 template <class PGraph> void TakeStat(const PGraph& Graph, const TSecTm& Time, TFSet StatFSet, const TStr& GraphName); 00107 template <class PGraph> void TakeBasicStat(const PGraph& Graph, const bool& IsMxWcc=false); 00108 template <class PGraph> void TakeBasicStat(const PGraph& Graph, TFSet FSet, const bool& IsMxWcc=false); 00109 template <class PGraph> void TakeDegDistr(const PGraph& Graph); 00110 template <class PGraph> void TakeDegDistr(const PGraph& Graph, TFSet StatFSet); 00111 template <class PGraph> void TakeDiam(const PGraph& Graph, const bool& IsMxWcc=false); 00112 template <class PGraph> void TakeDiam(const PGraph& Graph, TFSet StatFSet, const bool& IsMxWcc=false); 00113 template <class PGraph> void TakeConnComp(const PGraph& Graph); 00114 template <class PGraph> void TakeConnComp(const PGraph& Graph, TFSet StatFSet); 00115 template <class PGraph> void TakeClustCf(const PGraph& Graph, const int& SampleNodes=-1); 00116 template <class PGraph> void TakeTriadPart(const PGraph& Graph); 00117 void TakeSpectral(const PNGraph& Graph, const int _TakeSngVals = -1); 00118 void TakeSpectral(const PNGraph& Graph, TFSet StatFSet, int _TakeSngVals = -1); 00119 00120 void Plot(const TGStatDistr& Distr, const TStr& FNmPref, TStr Desc=TStr(), bool PowerFit=false) const; 00121 void Plot(const TFSet& FSet, const TStr& FNmPref, TStr Desc=TStr(), bool PowerFit=false) const; 00122 void PlotAll(const TStr& FNmPref, TStr Desc=TStr(), bool PowerFit=false) const; 00123 void DumpValStat(); 00124 00125 void AvgGStat(const PGStatVec& GStatVec, const bool& ClipAt1=false); 00126 void AvgGStat(const TGStatV& GStatV, const bool& ClipAt1=false); 00127 00128 // take graph statistics (see TTakeGStat) 00129 static TStr GetDistrStr(const TGStatDistr& Distr); 00130 static TStr GetValStr(const TGStatVal& Val); 00131 static TPlotInfo GetPlotInfo(const TGStatVal& Val); 00132 static TPlotInfo GetPlotInfo(const TGStatDistr& Distr); 00133 static TFSet NoStat(); 00134 static TFSet BasicStat(); 00135 static TFSet DegDStat(); 00136 static TFSet NoDiamStat(); 00137 static TFSet NoDistrStat(); 00138 static TFSet NoSvdStat(); 00139 static TFSet AllStat(); 00140 00141 friend class TCmpByVal; 00142 friend class TPt<TGStat>; 00143 }; 00144 00147 class TGStatVec { 00148 public: 00149 static uint MinNodesEdges; 00150 private: 00151 TCRef CRef; 00152 TTmUnit TmUnit; 00153 TFSet StatFSet; 00154 TGStatV GStatV; // each snapshot (TVec<PGStat>) 00155 public: 00156 TGStatVec(const TTmUnit& _TmUnit=tmu1Sec); 00157 TGStatVec(const TTmUnit& _TmUnit, const TFSet& TakeGrowthStat); 00158 TGStatVec(const TGStatVec& GStat); 00159 static PGStatVec New(const TTmUnit& _TmUnit=tmu1Sec); 00160 static PGStatVec New(const TTmUnit& _TmUnit, const TFSet& TakeGrowthStat); 00161 static PGStatVec Load(TSIn& SIn) { return new TGStatVec(SIn); } 00162 TGStatVec(TSIn& SIn); 00163 void Save(TSOut& SOut) const; 00164 TGStatVec& operator = (const TGStatVec& GStat); 00165 00166 PGStat Add(); 00167 PGStat Add(const TSecTm& Time, TStr GraphNm=TStr()); 00168 void Add(const PGStat& Growth) { GStatV.Add(Growth); } 00169 void Add(const PNGraph& Graph, const TSecTm& Time, const TStr& GraphNm=TStr()); 00170 void Add(const PNEGraph& Graph, const TSecTm& Time, const TStr& GraphNm=TStr()); 00171 void Clr() { GStatV.Clr(); } 00172 void Sort(const TGStatVal& SortBy=gsvNodes, const bool& Asc=true); 00173 00174 int Len() const { return GStatV.Len(); } 00175 bool Empty() const { return GStatV.Empty(); } 00176 PGStat operator[](const int& ValN) const { return GStatV[ValN]; } 00177 PGStat At(const int& ValN) const { return GStatV[ValN]; } 00178 PGStat Last() const { return GStatV.Last(); } 00179 const TGStatV& GetGStatV() const { return GStatV; } 00180 00181 void Del(const int& ValN) { GStatV.Del(ValN); } 00182 void DelLast() { GStatV.DelLast(); } 00183 void DelBefore(const TSecTm& Tm); 00184 void DelAfter(const TSecTm& Tm); 00185 void DelSmallNodes(const int& MinNodes); 00186 00187 void SetTmUnit(const TTmUnit& TimeUnit) { TmUnit = TimeUnit; } 00188 TTmUnit GetTmUnit() const { return TmUnit; } 00189 void SetTakeStat(const TFSet& TakeStatSet) { StatFSet = TakeStatSet; } 00190 bool HasVal(const TGStatVal& Stat) const { return StatFSet.In(Stat); } 00191 bool HasDistr(const TGStatDistr& Stat) const { return StatFSet.In(Stat); } 00192 00193 void GetValV(const TGStatVal& XVal, const TGStatVal& YVal, TFltPrV& ValV) const; 00194 PGStat GetAvgGStat(const bool& ClipAt1=false); 00195 00196 void Plot(const TGStatVal& XVal, const TGStatVal& YVal, const TStr& OutFNm, TStr& Desc, 00197 const TGpScaleTy& Scale=gpsAuto, const bool& PowerFit=false) const; 00198 void PlotAllVsX(const TGStatVal& XVal, const TStr& OutFNm, TStr Desc=TStr(), const TGpScaleTy& Scale=gpsAuto, const bool& PowerFit=false) const; 00199 void ImposeDistr(const TGStatDistr& Distr, const TStr& FNmPref, TStr Desc=TStr(), const bool& ExpBin=false, 00200 const bool& PowerFit=false, const TGpSeriesTy& PlotWith=gpwLinesPoints, const TStr& Style="") const; 00201 00202 void SaveTxt(const TStr& FNmPref, const TStr& Desc) const; 00203 friend class TPt<TGStatVec>; 00204 }; 00205 00207 // Implementation 00208 template <class PGraph> 00209 void TGStat::TakeStat(const PGraph& Graph, const TSecTm& _Time, TFSet StatFSet, const TStr& GraphName) { 00210 printf("**TakeStat: G(%u, %u)\n", Graph->GetNodes(), Graph->GetEdges()); 00211 TExeTm ExeTm, FullTm; 00212 Time = _Time; 00213 GraphNm = GraphName; 00214 if (StatFSet.In(gsvNone)) { return; } 00215 TakeBasicStat(Graph, false); 00216 if (StatFSet.In(gsdWcc)) { 00217 TakeBasicStat(TSnap::GetMxWcc(Graph), true); 00218 } 00219 // degrees 00220 TakeDegDistr(Graph, StatFSet); 00221 if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops) || 00222 StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops) || StatFSet.In(gsdWcc) || StatFSet.In(gsdScc) || 00223 StatFSet.In(gsdClustCf) || StatFSet.In(gsvClustCf) || StatFSet.In(gsdTriadPart)) { 00224 PNGraph NGraph = TSnap::ConvertGraph<PNGraph>(Graph, true); 00225 // diameter 00226 TakeDiam(NGraph, StatFSet, false); 00227 // components 00228 TakeConnComp(NGraph, StatFSet); 00229 // spectral 00230 TakeSpectral(NGraph, StatFSet, -1); 00231 // clustering coeffient 00232 if (StatFSet.In(gsdClustCf) || StatFSet.In(gsvClustCf)) { 00233 TakeClustCf(NGraph); } 00234 if (StatFSet.In(gsdTriadPart)) { 00235 TakeTriadPart(NGraph); } 00236 if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffWccDiam)) { 00237 TakeDiam(TSnap::GetMxWcc(NGraph), StatFSet, true); } 00238 printf(" [%s]\n", FullTm.GetTmStr()); 00239 } 00240 } 00241 00242 template <class PGraph> 00243 void TGStat::TakeBasicStat(const PGraph& Graph, const bool& IsMxWcc) { 00244 TakeBasicStat(Graph, TFSet() | gsvBiDirEdges | gsvWccBiDirEdges, IsMxWcc); 00245 } 00246 00247 template <class PGraph> 00248 void TGStat::TakeBasicStat(const PGraph& Graph, TFSet FSet, const bool& IsMxWcc) { 00249 if (! IsMxWcc) { 00250 // gsvNodes, gsvZeroNodes, gsvNonZNodes, gsvSrcNodes, gsvDstNodes, 00251 // gsvEdges, gsvUniqEdges, gsvBiDirEdges 00252 printf("basic wcc..."); 00253 const int Nodes = Graph->GetNodes(); 00254 SetVal(gsvNodes, Nodes); 00255 SetVal(gsvZeroNodes, TSnap::CntDegNodes(Graph, 0)); 00256 SetVal(gsvNonZNodes, Nodes - GetVal(gsvZeroNodes)); 00257 SetVal(gsvSrcNodes, Nodes - TSnap::CntOutDegNodes(Graph, 0)); 00258 SetVal(gsvDstNodes, Nodes - TSnap::CntInDegNodes(Graph, 0)); 00259 SetVal(gsvEdges, Graph->GetEdges()); 00260 if (! Graph->HasFlag(gfMultiGraph)) { SetVal(gsvUniqEdges, Graph->GetEdges()); } 00261 else { SetVal(gsvUniqEdges, TSnap::CntUniqDirEdges(Graph)); } 00262 if (FSet.In(gsvBiDirEdges)) { 00263 if (Graph->HasFlag(gfDirected)) { SetVal(gsvBiDirEdges, TSnap::CntUniqBiDirEdges(Graph)); } 00264 else { SetVal(gsvUniqEdges, GetVal(gsvEdges)); } 00265 } 00266 printf("\n"); 00267 } else { 00268 // gsvWccNodes, gsvWccSrcNodes, gsvWccDstNodes, gsvWccEdges, gsvWccUniqEdges, gsvWccBiDirEdges 00269 printf("basic..."); 00270 const int Nodes = Graph->GetNodes(); 00271 SetVal(gsvWccNodes, Nodes); 00272 SetVal(gsvWccSrcNodes, Nodes - TSnap::CntOutDegNodes(Graph, 0)); 00273 SetVal(gsvWccDstNodes, Nodes - TSnap::CntInDegNodes(Graph, 0)); 00274 SetVal(gsvWccEdges, Graph->GetEdges()); 00275 if (! Graph->HasFlag(gfMultiGraph)) { SetVal(gsvWccUniqEdges, Graph->GetEdges()); } 00276 else { SetVal(gsvWccUniqEdges, TSnap::CntUniqDirEdges(Graph)); } 00277 if (FSet.In(gsvBiDirEdges)) { 00278 if (Graph->HasFlag(gfDirected)) { SetVal(gsvWccBiDirEdges, TSnap::CntUniqBiDirEdges(Graph)); } 00279 else { SetVal(gsvUniqEdges, GetVal(gsvEdges)); } 00280 } 00281 printf("\n"); 00282 } 00283 } 00284 00285 template <class PGraph> 00286 void TGStat::TakeDegDistr(const PGraph& Graph) { 00287 TakeDegDistr(Graph, TFSet() | gsdInDeg | gsdOutDeg); 00288 } 00289 00290 template <class PGraph> 00291 void TGStat::TakeDegDistr(const PGraph& Graph, TFSet StatFSet) { 00292 // degree distribution 00293 if (StatFSet.In(gsdOutDeg) || StatFSet.In(gsdOutDeg)) { 00294 printf("deg "); } 00295 if (StatFSet.In(gsdInDeg)) { 00296 printf(" in "); 00297 TFltPrV& InDegV = DistrStatH.AddDat(gsdInDeg); 00298 TSnap::GetInDegCnt(Graph, InDegV); 00299 } 00300 if (StatFSet.In(gsdOutDeg)) { 00301 printf(" out "); 00302 TFltPrV& OutDegV = DistrStatH.AddDat(gsdOutDeg); 00303 TSnap::GetOutDegCnt(Graph, OutDegV); 00304 } 00305 if (StatFSet.In(gsdOutDeg) || StatFSet.In(gsdOutDeg)) { 00306 printf("\n"); } 00307 } 00308 00309 template <class PGraph> 00310 void TGStat::TakeDiam(const PGraph& Graph, const bool& IsMxWcc) { 00311 TakeDiam(Graph, TFSet() | gsvFullDiam | gsvEffDiam | gsdHops | 00312 gsvEffWccDiam| gsdWccHops, IsMxWcc); 00313 } 00314 00315 template <class PGraph> 00316 void TGStat::TakeDiam(const PGraph& Graph, TFSet StatFSet, const bool& IsMxWcc) { 00317 TExeTm ExeTm; 00318 if (! IsMxWcc) { 00319 if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops)) { 00320 printf("ANF diam %d runs ", NDiamRuns); } 00321 bool Line=false; 00322 if (StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops)) { 00323 TMom DiamMom; ExeTm.Tick(); 00324 TIntFltKdV DistNbrsV; 00325 for (int r = 0; r < NDiamRuns; r++) { 00326 TSnap::GetAnf(Graph, DistNbrsV, -1, false, 32); 00327 DiamMom.Add(TSnap::TSnapDetail::CalcEffDiam(DistNbrsV, 0.9)); 00328 printf("."); 00329 } 00330 DiamMom.Def(); 00331 SetVal(gsvEffDiam, DiamMom.GetMean()); 00332 SetVal(gsvEffDiamDev, DiamMom.GetSDev()); 00333 TFltPrV& HopsV = DistrStatH.AddDat(gsdHops); 00334 HopsV.Gen(DistNbrsV.Len(), 0); 00335 for (int i = 0; i < DistNbrsV.Len(); i++) { 00336 HopsV.Add(TFltPr(DistNbrsV[i].Key(), DistNbrsV[i].Dat)); } 00337 printf(" ANF-eff %.1f[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); 00338 Line=true; 00339 } 00340 if (Line) { printf("\n"); } 00341 } else { 00342 if (StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops)) { printf("wcc diam "); } 00343 bool Line=false; 00344 if (StatFSet.In(gsvFullDiam)) { 00345 TMom DiamMom; ExeTm.Tick(); 00346 for (int r = 0; r < NDiamRuns; r++) { 00347 DiamMom.Add(TSnap::GetBfsFullDiam(Graph, 1, false)); 00348 printf("."); } 00349 DiamMom.Def(); 00350 SetVal(gsvFullDiam, DiamMom.GetMean()); 00351 SetVal(gsvFullDiamDev, DiamMom.GetSDev()); 00352 printf(" BFS-full %g[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); 00353 Line=true; 00354 } 00355 if (StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops)) { 00356 TMom DiamMom; ExeTm.Tick(); 00357 TIntFltKdV DistNbrsV; 00358 for (int r = 0; r < NDiamRuns; r++) { 00359 TSnap::GetAnf(Graph, DistNbrsV, -1, false, 32); 00360 DiamMom.Add(TSnap::TSnapDetail::CalcEffDiam(DistNbrsV, 0.9)); 00361 printf("."); 00362 } 00363 DiamMom.Def(); 00364 SetVal(gsvEffWccDiam, DiamMom.GetMean()); 00365 SetVal(gsvEffWccDiamDev, DiamMom.GetSDev()); 00366 TFltPrV& WccHopsV = DistrStatH.AddDat(gsdWccHops); 00367 WccHopsV.Gen(DistNbrsV.Len(), 0); 00368 for (int i = 0; i < DistNbrsV.Len(); i++) { 00369 WccHopsV.Add(TFltPr(DistNbrsV[i].Key(), DistNbrsV[i].Dat)); } 00370 printf(" ANF-wccEff %.1f[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); 00371 Line=true; 00372 } 00373 if (Line) { printf("\n"); } 00374 } 00375 } 00376 00377 template <class PGraph> 00378 void TGStat::TakeConnComp(const PGraph& Graph) { 00379 TakeConnComp(Graph, TFSet() | gsdWcc | gsdScc); 00380 } 00381 00382 template <class PGraph> 00383 void TGStat::TakeConnComp(const PGraph& Graph, TFSet StatFSet) { 00384 if (StatFSet.In(gsdWcc)) { 00385 printf("wcc "); 00386 TIntPrV WccSzCntV1; 00387 TSnap::GetWccSzCnt(Graph, WccSzCntV1); 00388 TFltPrV& WccSzCntV = DistrStatH.AddDat(gsdWcc); 00389 WccSzCntV.Gen(WccSzCntV1.Len(), 0); 00390 for (int i = 0; i < WccSzCntV1.Len(); i++) 00391 WccSzCntV.Add(TFltPr(WccSzCntV1[i].Val1(), WccSzCntV1[i].Val2())); 00392 } 00393 if (StatFSet.In(gsdScc)) { 00394 printf("scc "); 00395 TIntPrV SccSzCntV1; 00396 TSnap::GetSccSzCnt(Graph, SccSzCntV1); 00397 TFltPrV& SccSzCntV = DistrStatH.AddDat(gsdScc); 00398 SccSzCntV.Gen(SccSzCntV1.Len(), 0); 00399 for (int i = 0; i < SccSzCntV1.Len(); i++) 00400 SccSzCntV.Add(TFltPr(SccSzCntV1[i].Val1(), SccSzCntV1[i].Val2())); 00401 } 00402 if (StatFSet.In(gsdWcc) || StatFSet.In(gsdScc)) { printf("\n"); } 00403 } 00404 00405 template <class PGraph> 00406 void TGStat::TakeClustCf(const PGraph& Graph, const int& SampleNodes) { 00407 printf("clustCf "); 00408 TFltPrV& ClustCfV = DistrStatH.AddDat(gsdClustCf); 00409 int Open, Close; 00410 const double ClustCf = TSnap::GetClustCf(Graph, ClustCfV, Close, Open, SampleNodes); 00411 SetVal(gsvClustCf, ClustCf); 00412 SetVal(gsvOpenTriads, Open); 00413 SetVal(gsvClosedTriads, Close); 00414 } 00415 00416 template <class PGraph> 00417 void TGStat::TakeTriadPart(const PGraph& Graph) { 00418 printf("triadParticip "); 00419 TFltPrV& TriadCntV = DistrStatH.AddDat(gsdTriadPart); 00420 TIntPrV CntV; 00421 TSnap::GetTriadParticip(Graph, CntV); 00422 TriadCntV.Gen(CntV.Len(), 0); 00423 for (int i = 0; i < CntV.Len(); i++) { 00424 TriadCntV.Add(TFltPr(CntV[i].Val1(), CntV[i].Val2())); 00425 } 00426 }