SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <gstat.h>
Classes | |
class | TCmpByVal |
Public Types | |
typedef TQuad< TStr, TStr, TStr, TGpScaleTy > | TPlotInfo |
Public Member Functions | |
TGStat (const TSecTm &GraphTm=TSecTm(), const TStr &GraphName=TStr()) | |
TGStat (const PNGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphName=TStr()) | |
TGStat (const PNEGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphName=TStr()) | |
template<class PGraph > | |
TGStat (const PGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphName=TStr()) | |
TGStat (const TGStat &GStat) | |
TGStat (TSIn &SIn) | |
void | Save (TSOut &SOut) const |
template<class PGraph > | |
PGStat | New (const PGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphNm=TStr()) |
PGStat | Clone () const |
TGStat & | operator= (const TGStat &GStat) |
bool | operator== (const TGStat &GStat) const |
bool | operator< (const TGStat &GStat) const |
int | GetYear () const |
int | GetMonth () const |
int | GetDay () const |
int | GetHour () const |
int | GetMin () const |
int | GetSec () const |
TStr | GetTmStr () const |
void | SetTm (const TSecTm &GraphTm) |
TStr | GetNm () const |
void | SetNm (const TStr &GraphName) |
int | GetVals () const |
bool | HasVal (const TGStatVal &StatVal) const |
double | GetVal (const TGStatVal &StatVal) const |
void | SetVal (const TGStatVal &StatVal, const double &Val) |
int | GetDistrs () const |
bool | HasDistr (const TGStatDistr &Distr) const |
const TFltPrV & | GetDistr (const TGStatDistr &Distr) const |
void | GetDistr (const TGStatDistr &Distr, TFltPrV &FltPrV) const |
void | SetDistr (const TGStatDistr &Distr, const TFltPrV &FltPrV) |
int | GetNodes () const |
int | GetEdges () const |
void | TakeStat (const PNGraph &Graph, const TSecTm &Time, TFSet StatFSet, const TStr &GraphName) |
template<class PGraph > | |
void | TakeStat (const PGraph &Graph, const TSecTm &Time, TFSet StatFSet, const TStr &GraphName) |
template<class PGraph > | |
void | TakeBasicStat (const PGraph &Graph, const bool &IsMxWcc=false) |
template<class PGraph > | |
void | TakeBasicStat (const PGraph &Graph, TFSet FSet, const bool &IsMxWcc=false) |
template<class PGraph > | |
void | TakeDegDistr (const PGraph &Graph) |
template<class PGraph > | |
void | TakeDegDistr (const PGraph &Graph, TFSet StatFSet) |
template<class PGraph > | |
void | TakeDiam (const PGraph &Graph, const bool &IsMxWcc=false) |
template<class PGraph > | |
void | TakeDiam (const PGraph &Graph, TFSet StatFSet, const bool &IsMxWcc=false) |
template<class PGraph > | |
void | TakeConnComp (const PGraph &Graph) |
template<class PGraph > | |
void | TakeConnComp (const PGraph &Graph, TFSet StatFSet) |
template<class PGraph > | |
void | TakeClustCf (const PGraph &Graph, const int &SampleNodes=-1) |
template<class PGraph > | |
void | TakeTriadPart (const PGraph &Graph) |
void | TakeSpectral (const PNGraph &Graph, const int _TakeSngVals=-1) |
void | TakeSpectral (const PNGraph &Graph, TFSet StatFSet, int _TakeSngVals=-1) |
void | Plot (const TGStatDistr &Distr, const TStr &FNmPref, TStr Desc=TStr(), bool PowerFit=false) const |
void | Plot (const TFSet &FSet, const TStr &FNmPref, TStr Desc=TStr(), bool PowerFit=false) const |
void | PlotAll (const TStr &FNmPref, TStr Desc=TStr(), bool PowerFit=false) const |
void | DumpValStat () |
void | AvgGStat (const PGStatVec &GStatVec, const bool &ClipAt1=false) |
void | AvgGStat (const TGStatV &GStatV, const bool &ClipAt1=false) |
Static Public Member Functions | |
static PGStat | New (const TSecTm &Time=TSecTm(), const TStr &GraphName=TStr()) |
static PGStat | New (const PNGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphNm=TStr()) |
static PGStat | New (const PNEGraph &Graph, const TSecTm &Time, TFSet StatFSet=TFSet(), const TStr &GraphNm=TStr()) |
static PGStat | Load (TSIn &SIn) |
static TStr | GetDistrStr (const TGStatDistr &Distr) |
static TStr | GetValStr (const TGStatVal &Val) |
static TPlotInfo | GetPlotInfo (const TGStatVal &Val) |
static TPlotInfo | GetPlotInfo (const TGStatDistr &Distr) |
static TFSet | NoStat () |
static TFSet | BasicStat () |
static TFSet | DegDStat () |
static TFSet | NoDiamStat () |
static TFSet | NoDistrStat () |
static TFSet | NoSvdStat () |
static TFSet | AllStat () |
Public Attributes | |
TSecTm | Time |
TStr | GraphNm |
TIntFltH | ValStatH |
THash< TInt, TFltPrV > | DistrStatH |
Static Public Attributes | |
static int | NDiamRuns = 10 |
static int | TakeSngVals = 100 |
Private Attributes | |
TCRef | CRef |
Static Private Attributes | |
static const TFltPrV | EmptyV = TFltPrV() |
Friends | |
class | TCmpByVal |
class | TPt< TGStat > |
typedef TQuad<TStr, TStr, TStr, TGpScaleTy> TGStat::TPlotInfo |
TGStat::TGStat | ( | const TSecTm & | GraphTm = TSecTm() , |
const TStr & | GraphName = TStr() |
||
) |
TGStat::TGStat | ( | const PNGraph & | Graph, |
const TSecTm & | Time, | ||
TFSet | StatFSet = TFSet() , |
||
const TStr & | GraphName = TStr() |
||
) |
Definition at line 25 of file gstat.cpp.
References TakeStat().
{ TakeStat(Graph, GraphTm, StatFSet, GraphName); }
TGStat::TGStat | ( | const PNEGraph & | Graph, |
const TSecTm & | Time, | ||
TFSet | StatFSet = TFSet() , |
||
const TStr & | GraphName = TStr() |
||
) |
Definition at line 29 of file gstat.cpp.
References TakeStat().
{ TakeStat(Graph, GraphTm, StatFSet, GraphName); }
TGStat::TGStat | ( | const PGraph & | Graph, |
const TSecTm & | Time, | ||
TFSet | StatFSet = TFSet() , |
||
const TStr & | GraphName = TStr() |
||
) | [inline] |
Definition at line 62 of file gstat.h.
References TakeStat().
{ TakeStat(Graph, Time, StatFSet, GraphName); }
TGStat::TGStat | ( | const TGStat & | GStat | ) |
Definition at line 32 of file gstat.cpp.
: Time(GStat.Time), GraphNm(GStat.GraphNm), ValStatH(GStat.ValStatH), DistrStatH(GStat.DistrStatH) { }
TGStat::TGStat | ( | TSIn & | SIn | ) |
TFSet TGStat::AllStat | ( | ) | [static] |
Definition at line 344 of file gstat.cpp.
References gsdClustCf, gsdHops, gsdInDeg, gsdOutDeg, gsdScc, gsdSngVal, gsdSngVec, gsdTriadPart, gsdWcc, gsdWccHops, and gsvFullDiam.
Referenced by TFfGGen::GenFFGraphs(), main(), and TGStatVec::TGStatVec().
{ return TFSet() | gsdInDeg | gsdOutDeg | gsdWcc | gsdScc | gsdHops | gsdWccHops | gsdClustCf | gsdTriadPart | gsdSngVec | gsdSngVal | gsvFullDiam; }
void TGStat::AvgGStat | ( | const PGStatVec & | GStatVec, |
const bool & | ClipAt1 = false |
||
) |
void TGStat::AvgGStat | ( | const TGStatV & | GStatV, |
const bool & | ClipAt1 = false |
||
) |
Definition at line 197 of file gstat.cpp.
References TMom::Add(), THash< TKey, TDat, THashFunc >::AddDat(), TMom::Def(), TVec< TVal >::Empty(), THash< TKey, TDat, THashFunc >::GetKeyDatPrV(), TMom::GetMean(), GetVal(), TMom::GetVals(), GraphNm, gsdMx, gsdUndef, gsvMx, HasDistr(), HasVal(), IAssert, TMom::IsUsable(), TVec< TVal >::Len(), SetDistr(), SetVal(), and Time.
{ if (GStatV.Empty()) return; Time = GStatV[0]->Time; GraphNm = GStatV[0]->GraphNm; // values for (int statVal = 0; statVal > gsvMx; statVal++) { const TGStatVal GStatVal = TGStatVal(statVal); TMom Mom; for (int i = 0; i < GStatV.Len(); i++) { if (GStatV[i]->HasVal(GStatVal)) { Mom.Add(GStatV[i]->GetVal(GStatVal)); } } Mom.Def(); if (Mom.IsUsable()) { IAssert(Mom.GetVals() == GStatV.Len()); // all must have the value SetVal(GStatVal, Mom.GetMean()); } } // distributions for (int distr = gsdUndef; distr < gsdMx; distr++) { const TGStatDistr GStatDistr = TGStatDistr(distr); THash<TFlt, TFlt> ValToSumH; int DistrCnt = 0; for (int i = 0; i < GStatV.Len(); i++) { if (GStatV[i]->HasDistr(GStatDistr)) { const TFltPrV& D = GStatV[i]->GetDistr(GStatDistr); for (int d = 0; d < D.Len(); d++) { ValToSumH.AddDat(D[d].Val1) += D[d].Val2; } DistrCnt++; } } IAssert(DistrCnt==0 || DistrCnt==GStatV.Len()); // all must have distribution TFltPrV AvgStatV; ValToSumH.GetKeyDatPrV(AvgStatV); AvgStatV.Sort(); for (int i = 0; i < AvgStatV.Len(); i++) { AvgStatV[i].Val2 /= double(DistrCnt); if (ClipAt1 && AvgStatV[i].Val2 < 1) { AvgStatV[i].Val2 = 1; } } SetDistr(GStatDistr, AvgStatV); } }
TFSet TGStat::BasicStat | ( | ) | [static] |
PGStat TGStat::Clone | ( | ) | const [inline] |
TFSet TGStat::DegDStat | ( | ) | [static] |
void TGStat::DumpValStat | ( | ) |
Definition at line 185 of file gstat.cpp.
References GetVal(), GetValStr(), gsvMx, gsvNone, and HasVal().
{ for (int val = gsvNone; val < gsvMx; val++) { const TGStatVal Val = TGStatVal(val); if (! HasVal(Val)) { continue; } printf(" %s\t%g\n", GetValStr(Val).CStr(), GetVal(Val)); } }
int TGStat::GetDay | ( | ) | const [inline] |
Definition at line 83 of file gstat.h.
References TSecTm::GetDayN().
const TFltPrV & TGStat::GetDistr | ( | const TGStatDistr & | Distr | ) | const |
Definition at line 88 of file gstat.cpp.
References DistrStatH, EmptyV, THash< TKey, TDat, THashFunc >::GetDat(), and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by GetDistr(), and Plot().
{ if (! DistrStatH.IsKey(int(Distr))) { return EmptyV; } return DistrStatH.GetDat(int(Distr)); }
void TGStat::GetDistr | ( | const TGStatDistr & | Distr, |
TFltPrV & | FltPrV | ||
) | const |
Definition at line 97 of file gstat.cpp.
References GetDistr().
{ FltPrV = GetDistr(Distr); }
int TGStat::GetDistrs | ( | ) | const [inline] |
Definition at line 96 of file gstat.h.
References DistrStatH, and THash< TKey, TDat, THashFunc >::Len().
{ return DistrStatH.Len(); }
TStr TGStat::GetDistrStr | ( | const TGStatDistr & | Distr | ) | [static] |
Definition at line 239 of file gstat.cpp.
References Fail, gsdClustCf, gsdHops, gsdInDeg, gsdMx, gsdOutDeg, gsdScc, gsdSngVal, gsdSngVec, gsdTriadPart, gsdUndef, gsdWcc, and gsdWccHops.
{ switch (Distr) { case gsdUndef : return TStr("Undef"); case gsdInDeg : return "InDeg"; case gsdOutDeg : return "OutDeg"; case gsdWcc : return "WccDist"; case gsdScc : return "SccDist"; case gsdHops : return "Hops"; case gsdWccHops : return "WccHops"; case gsdSngVal : return "SngVal"; case gsdSngVec : return "SngVec"; case gsdClustCf : return "ClustCf"; case gsdTriadPart : return "TriadPart"; case gsdMx: return TStr("Mx"); default: Fail; return TStr(); }; }
int TGStat::GetEdges | ( | ) | const [inline] |
int TGStat::GetHour | ( | ) | const [inline] |
Definition at line 84 of file gstat.h.
References TSecTm::GetHourN().
int TGStat::GetMin | ( | ) | const [inline] |
Definition at line 85 of file gstat.h.
References TSecTm::GetMinN().
int TGStat::GetMonth | ( | ) | const [inline] |
Definition at line 82 of file gstat.h.
References TSecTm::GetMonthN().
TStr TGStat::GetNm | ( | ) | const [inline] |
int TGStat::GetNodes | ( | ) | const [inline] |
TGStat::TPlotInfo TGStat::GetPlotInfo | ( | const TGStatVal & | Val | ) | [static] |
TGStat::TPlotInfo TGStat::GetPlotInfo | ( | const TGStatDistr & | Distr | ) | [static] |
Definition at line 301 of file gstat.cpp.
References Fail, gpsLog10XY, gpsLog10Y, gsdClustCf, gsdHops, gsdInDeg, gsdMx, gsdOutDeg, gsdScc, gsdSngVal, gsdSngVec, gsdTriadPart, gsdUndef, gsdWcc, and gsdWccHops.
{ switch (Distr) { case gsdUndef : Fail; return TPlotInfo(); case gsdInDeg : return TPlotInfo("inDeg", "In-degree, k", "Count", gpsLog10XY); case gsdOutDeg : return TPlotInfo("outDeg", "Out-degree, k", "Count", gpsLog10XY); case gsdWcc : return TPlotInfo("wcc", "WCC size", "Count", gpsLog10XY); case gsdScc : return TPlotInfo("scc", "SCC size", "Count", gpsLog10XY); case gsdHops : return TPlotInfo("hop", "Number of hops, h", "Reachable pairs of nodes inside h hops", gpsLog10Y); case gsdWccHops : return TPlotInfo("wccHop", "Number of hops, h", "Reachable pairs of nodes inside h hops in WCC", gpsLog10Y); case gsdSngVal : return TPlotInfo("sval", "Rank", "Singular value", gpsLog10XY); case gsdSngVec : return TPlotInfo("svec", "Rank", "Left singular vector", gpsLog10XY); case gsdClustCf : return TPlotInfo("ccf", "Degree, k", "Clustering coefficient, <C(k)>", gpsLog10XY); case gsdTriadPart : return TPlotInfo("triad", "Number of triads adjacent to a node", "Number of such nodes", gpsLog10XY); case gsdMx : Fail; default: Fail; return TPlotInfo(); }; }
int TGStat::GetSec | ( | ) | const [inline] |
Definition at line 86 of file gstat.h.
References TSecTm::GetSecN().
TStr TGStat::GetTmStr | ( | ) | const [inline] |
Definition at line 87 of file gstat.h.
References TSecTm::GetStr().
Referenced by TGStatVec::SaveTxt().
double TGStat::GetVal | ( | const TGStatVal & | StatVal | ) | const |
Definition at line 77 of file gstat.cpp.
References TSecTm::GetAbsSecs(), THash< TKey, TDat, THashFunc >::GetDat(), gsvNodes, gsvTime, gsvWccNodes, gsvWccSize, THash< TKey, TDat, THashFunc >::IsKey(), Time, and ValStatH.
Referenced by AvgGStat(), DumpValStat(), GetEdges(), GetNodes(), TGStat::TCmpByVal::operator()(), TGStatVec::SaveTxt(), and TakeBasicStat().
{ if (StatVal == gsvTime) { return Time.GetAbsSecs(); } if (StatVal == gsvWccSize) { return GetVal(gsvWccNodes) / GetVal(gsvNodes); } if (! ValStatH.IsKey(int(StatVal))) { return -1.0; } return ValStatH.GetDat(int(StatVal)); }
int TGStat::GetVals | ( | ) | const [inline] |
TStr TGStat::GetValStr | ( | const TGStatVal & | Val | ) | [static] |
Definition at line 257 of file gstat.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::Empty(), THash< TKey, TDat, THashFunc >::GetDat(), gsvBiDirEdges, gsvClosedTriads, gsvClustCf, gsvDstNodes, gsvEdges, gsvEffDiam, gsvEffDiamDev, gsvEffWccDiam, gsvEffWccDiamDev, gsvFullDiam, gsvFullDiamDev, gsvFullWccDiam, gsvFullWccDiamDev, gsvMx, gsvNodes, gsvNone, gsvNonZNodes, gsvOpenTriads, gsvSrcNodes, gsvTime, gsvUniqEdges, gsvWccBiDirEdges, gsvWccDstNodes, gsvWccEdges, gsvWccNodes, gsvWccSize, gsvWccSrcNodes, gsvWccUniqEdges, gsvZeroNodes, IAssert, and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by DumpValStat(), TGStat::TCmpByVal::operator()(), TGStatVec::Plot(), and TGStatVec::SaveTxt().
{ static TIntStrH ValTyStrH; if (ValTyStrH.Empty()) { ValTyStrH.AddDat(gsvNone, "None"); ValTyStrH.AddDat(gsvTime, "Time"); ValTyStrH.AddDat(gsvNodes, "Nodes"); ValTyStrH.AddDat(gsvZeroNodes, "ZeroNodes"); ValTyStrH.AddDat(gsvNonZNodes, "NonZNodes"); ValTyStrH.AddDat(gsvSrcNodes, "SrcNodes"); ValTyStrH.AddDat(gsvDstNodes, "DstNodes"); ValTyStrH.AddDat(gsvEdges, "Edges"); ValTyStrH.AddDat(gsvUniqEdges, "UniqEdges"); ValTyStrH.AddDat(gsvBiDirEdges, "BiDirEdges"); ValTyStrH.AddDat(gsvWccNodes, "WccNodes"); ValTyStrH.AddDat(gsvWccSrcNodes, "WccSrcNodes"); ValTyStrH.AddDat(gsvWccDstNodes, "WccDstNodes"); ValTyStrH.AddDat(gsvWccEdges, "WccEdges"); ValTyStrH.AddDat(gsvWccUniqEdges, "WccUniqEdges"); ValTyStrH.AddDat(gsvWccBiDirEdges, "WccBiDirEdges"); ValTyStrH.AddDat(gsvFullDiam, "FullDiam"); ValTyStrH.AddDat(gsvEffDiam, "EffDiam"); ValTyStrH.AddDat(gsvEffWccDiam, "EffWccDiam"); ValTyStrH.AddDat(gsvFullWccDiam, "FullWccDiam"); ValTyStrH.AddDat(gsvFullDiamDev, "FullDiamDev"); ValTyStrH.AddDat(gsvEffDiamDev, "EffDiamDev"); ValTyStrH.AddDat(gsvEffWccDiamDev, "EffWccDiamDev"); ValTyStrH.AddDat(gsvFullWccDiamDev, "FullWccDiamDev"); ValTyStrH.AddDat(gsvClustCf, "ClustCf"); ValTyStrH.AddDat(gsvOpenTriads, "OpenTr"); ValTyStrH.AddDat(gsvClosedTriads, "ClosedTr"); ValTyStrH.AddDat(gsvWccSize, "WccSize"); ValTyStrH.AddDat(gsvMx, "Mx"); } IAssert(ValTyStrH.IsKey(int(Val))); return ValTyStrH.GetDat(int(Val)); }
int TGStat::GetYear | ( | ) | const [inline] |
Definition at line 81 of file gstat.h.
References TSecTm::GetYearN().
bool TGStat::HasDistr | ( | const TGStatDistr & | Distr | ) | const [inline] |
Definition at line 97 of file gstat.h.
References DistrStatH, and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by AvgGStat(), and Plot().
{ return DistrStatH.IsKey(Distr); }
bool TGStat::HasVal | ( | const TGStatVal & | StatVal | ) | const |
Definition at line 71 of file gstat.cpp.
References gsvNodes, gsvTime, gsvWccNodes, gsvWccSize, TSecTm::IsDef(), THash< TKey, TDat, THashFunc >::IsKey(), Time, and ValStatH.
Referenced by AvgGStat(), DumpValStat(), and TGStat::TCmpByVal::operator()().
{ if (StatVal == gsvTime) { return Time.IsDef(); } if (StatVal == gsvWccSize) { return HasVal(gsvWccNodes) && HasVal(gsvNodes); } return ValStatH.IsKey(int(StatVal)); }
static PGStat TGStat::Load | ( | TSIn & | SIn | ) | [inline, static] |
static PGStat TGStat::New | ( | const TSecTm & | Time = TSecTm() , |
const TStr & | GraphName = TStr() |
||
) | [inline, static] |
Definition at line 67 of file gstat.h.
References TGStat().
Referenced by TGStatVec::Add().
{ return new TGStat(Time, GraphName); }
TFSet TGStat::NoDiamStat | ( | ) | [static] |
TFSet TGStat::NoDistrStat | ( | ) | [static] |
Definition at line 335 of file gstat.cpp.
References gsdHops, and gsdWccHops.
{ return TFSet() | gsdHops | gsdWccHops; }
TFSet TGStat::NoStat | ( | ) | [static] |
TFSet TGStat::NoSvdStat | ( | ) | [static] |
Definition at line 339 of file gstat.cpp.
References gsdClustCf, gsdHops, gsdInDeg, gsdOutDeg, gsdScc, gsdTriadPart, gsdWcc, and gsdWccHops.
{ return TFSet() | gsdInDeg | gsdOutDeg | gsdWcc | gsdScc | gsdHops | gsdWccHops | gsdClustCf | gsdTriadPart; }
bool TGStat::operator< | ( | const TGStat & | GStat | ) | const |
Definition at line 57 of file gstat.cpp.
References THash< TKey, TDat, THashFunc >::Empty(), THash< TKey, TDat, THashFunc >::GetDat(), gsvMx, gsvTime, THash< TKey, TDat, THashFunc >::IsKey(), Time, and ValStatH.
{ if (Time<GStat.Time) { return true; } if (Time>GStat.Time) { return false; } if (ValStatH.Empty() && ! GStat.ValStatH.Empty()) { return true; } if (GStat.ValStatH.Empty()) { return false; } for (int v = gsvTime; v < gsvMx; v++) { if (! ValStatH.IsKey(v) && ! GStat.ValStatH.IsKey(v)) { continue; } if (ValStatH.IsKey(v) && ! GStat.ValStatH.IsKey(v)) { return false; } if (! ValStatH.IsKey(v)) { return true; } if (ValStatH.GetDat(v) < GStat.ValStatH.GetDat(v)) { return true; } } return false; }
Definition at line 43 of file gstat.cpp.
References DistrStatH, GraphNm, Time, and ValStatH.
{ if (this != &GStat) { Time = GStat.Time; GraphNm = GStat.GraphNm; ValStatH = GStat.ValStatH; DistrStatH = GStat.DistrStatH; } return *this; }
bool TGStat::operator== | ( | const TGStat & | GStat | ) | const |
Definition at line 53 of file gstat.cpp.
References DistrStatH, Time, and ValStatH.
{ return Time==GStat.Time && ValStatH==GStat.ValStatH && DistrStatH==GStat.DistrStatH; }
void TGStat::Plot | ( | const TGStatDistr & | Distr, |
const TStr & | FNmPref, | ||
TStr | Desc = TStr() , |
||
bool | PowerFit = false |
||
) | const |
Definition at line 158 of file gstat.cpp.
References TGnuPlot::AddPlot(), TGnuPlot::AddPwrFit(), TStr::CStr(), TStr::Empty(), TStr::Fmt(), GetDistr(), GetEdges(), GetNodes(), GetPlotInfo(), TStr::GetUc(), gpwLines, gpwLinesPoints, gsdMx, gsdUndef, HasDistr(), TGnuPlot::SavePng(), TGnuPlot::SetScale(), TGnuPlot::SetXYLabel(), TQuad< TVal1, TVal2, TVal3, TVal4 >::Val1, TQuad< TVal1, TVal2, TVal3, TVal4 >::Val2, TQuad< TVal1, TVal2, TVal3, TVal4 >::Val3, and TQuad< TVal1, TVal2, TVal3, TVal4 >::Val4.
Referenced by Plot(), and PlotAll().
{ if (Desc.Empty()) Desc = FNmPref.GetUc(); if (! HasDistr(Distr) || Distr==gsdUndef || Distr==gsdMx) { return; } TPlotInfo Info = GetPlotInfo(Distr); TGnuPlot GnuPlot(Info.Val1+TStr(".")+FNmPref, TStr::Fmt("%s. G(%d, %d)", Desc.CStr(), GetNodes(),GetEdges())); GnuPlot.SetXYLabel(Info.Val2, Info.Val3); GnuPlot.SetScale(Info.Val4); const int plotId = GnuPlot.AddPlot(GetDistr(Distr), gpwLinesPoints, ""); if (PowerFit) { GnuPlot.AddPwrFit(plotId, gpwLines); } GnuPlot.SavePng(); }
void TGStat::Plot | ( | const TFSet & | FSet, |
const TStr & | FNmPref, | ||
TStr | Desc = TStr() , |
||
bool | PowerFit = false |
||
) | const |
Definition at line 170 of file gstat.cpp.
References gsdMx, gsdUndef, TFSet::In(), and Plot().
{ for (int d = gsdUndef; d < gsdMx; d++) { const TGStatDistr Distr = TGStatDistr(d); if (! FSet.In(Distr)) { continue; } Plot(Distr, FNmPref, Desc, PowerFit); } }
void TGStat::PlotAll | ( | const TStr & | FNmPref, |
TStr | Desc = TStr() , |
||
bool | PowerFit = false |
||
) | const |
Definition at line 178 of file gstat.cpp.
References gsdMx, gsdUndef, and Plot().
{ for (int d = gsdUndef; d < gsdMx; d++) { const TGStatDistr Distr = TGStatDistr(d); Plot(Distr, FNmPref, Desc, PowerFit); } }
void TGStat::Save | ( | TSOut & | SOut | ) | const |
Definition at line 38 of file gstat.cpp.
References DistrStatH, GraphNm, TSecTm::Save(), THash< TKey, TDat, THashFunc >::Save(), TStr::Save(), Time, and ValStatH.
void TGStat::SetDistr | ( | const TGStatDistr & | Distr, |
const TFltPrV & | FltPrV | ||
) |
Definition at line 93 of file gstat.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), and DistrStatH.
Referenced by AvgGStat().
{ DistrStatH.AddDat(Distr, FltPrV); }
void TGStat::SetNm | ( | const TStr & | GraphName | ) | [inline] |
void TGStat::SetTm | ( | const TSecTm & | GraphTm | ) | [inline] |
void TGStat::SetVal | ( | const TGStatVal & | StatVal, |
const double & | Val | ||
) |
Definition at line 84 of file gstat.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), and ValStatH.
Referenced by AvgGStat(), TTimeNet::PlotMissingPast(), TakeBasicStat(), TakeClustCf(), and TakeDiam().
void TGStat::TakeBasicStat | ( | const PGraph & | Graph, |
const bool & | IsMxWcc = false |
||
) |
Definition at line 243 of file gstat.h.
References gsvBiDirEdges, and gsvWccBiDirEdges.
Referenced by TTimeNet::PlotMissingPast(), and TakeStat().
{ TakeBasicStat(Graph, TFSet() | gsvBiDirEdges | gsvWccBiDirEdges, IsMxWcc); }
void TGStat::TakeBasicStat | ( | const PGraph & | Graph, |
TFSet | FSet, | ||
const bool & | IsMxWcc = false |
||
) |
Definition at line 248 of file gstat.h.
References TSnap::CntDegNodes(), TSnap::CntInDegNodes(), TSnap::CntOutDegNodes(), TSnap::CntUniqBiDirEdges(), TSnap::CntUniqDirEdges(), GetVal(), gfDirected, gfMultiGraph, gsvBiDirEdges, gsvDstNodes, gsvEdges, gsvNodes, gsvNonZNodes, gsvSrcNodes, gsvUniqEdges, gsvWccBiDirEdges, gsvWccDstNodes, gsvWccEdges, gsvWccNodes, gsvWccSrcNodes, gsvWccUniqEdges, gsvZeroNodes, TFSet::In(), and SetVal().
{ if (! IsMxWcc) { // gsvNodes, gsvZeroNodes, gsvNonZNodes, gsvSrcNodes, gsvDstNodes, // gsvEdges, gsvUniqEdges, gsvBiDirEdges printf("basic wcc..."); const int Nodes = Graph->GetNodes(); SetVal(gsvNodes, Nodes); SetVal(gsvZeroNodes, TSnap::CntDegNodes(Graph, 0)); SetVal(gsvNonZNodes, Nodes - GetVal(gsvZeroNodes)); SetVal(gsvSrcNodes, Nodes - TSnap::CntOutDegNodes(Graph, 0)); SetVal(gsvDstNodes, Nodes - TSnap::CntInDegNodes(Graph, 0)); SetVal(gsvEdges, Graph->GetEdges()); if (! Graph->HasFlag(gfMultiGraph)) { SetVal(gsvUniqEdges, Graph->GetEdges()); } else { SetVal(gsvUniqEdges, TSnap::CntUniqDirEdges(Graph)); } if (FSet.In(gsvBiDirEdges)) { if (Graph->HasFlag(gfDirected)) { SetVal(gsvBiDirEdges, TSnap::CntUniqBiDirEdges(Graph)); } else { SetVal(gsvUniqEdges, GetVal(gsvEdges)); } } printf("\n"); } else { // gsvWccNodes, gsvWccSrcNodes, gsvWccDstNodes, gsvWccEdges, gsvWccUniqEdges, gsvWccBiDirEdges printf("basic..."); const int Nodes = Graph->GetNodes(); SetVal(gsvWccNodes, Nodes); SetVal(gsvWccSrcNodes, Nodes - TSnap::CntOutDegNodes(Graph, 0)); SetVal(gsvWccDstNodes, Nodes - TSnap::CntInDegNodes(Graph, 0)); SetVal(gsvWccEdges, Graph->GetEdges()); if (! Graph->HasFlag(gfMultiGraph)) { SetVal(gsvWccUniqEdges, Graph->GetEdges()); } else { SetVal(gsvWccUniqEdges, TSnap::CntUniqDirEdges(Graph)); } if (FSet.In(gsvBiDirEdges)) { if (Graph->HasFlag(gfDirected)) { SetVal(gsvWccBiDirEdges, TSnap::CntUniqBiDirEdges(Graph)); } else { SetVal(gsvUniqEdges, GetVal(gsvEdges)); } } printf("\n"); } }
void TGStat::TakeClustCf | ( | const PGraph & | Graph, |
const int & | SampleNodes = -1 |
||
) |
Definition at line 406 of file gstat.h.
References THash< TKey, TDat, THashFunc >::AddDat(), DistrStatH, TSnap::GetClustCf(), gsdClustCf, gsvClosedTriads, gsvClustCf, gsvOpenTriads, and SetVal().
Referenced by TakeStat().
{ printf("clustCf "); TFltPrV& ClustCfV = DistrStatH.AddDat(gsdClustCf); int Open, Close; const double ClustCf = TSnap::GetClustCf(Graph, ClustCfV, Close, Open, SampleNodes); SetVal(gsvClustCf, ClustCf); SetVal(gsvOpenTriads, Open); SetVal(gsvClosedTriads, Close); }
void TGStat::TakeConnComp | ( | const PGraph & | Graph | ) |
Definition at line 378 of file gstat.h.
References gsdScc, and gsdWcc.
Referenced by TakeStat().
{ TakeConnComp(Graph, TFSet() | gsdWcc | gsdScc); }
void TGStat::TakeConnComp | ( | const PGraph & | Graph, |
TFSet | StatFSet | ||
) |
Definition at line 383 of file gstat.h.
References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), DistrStatH, TVec< TVal >::Gen(), TSnap::GetSccSzCnt(), TSnap::GetWccSzCnt(), gsdScc, gsdWcc, TFSet::In(), and TVec< TVal >::Len().
{ if (StatFSet.In(gsdWcc)) { printf("wcc "); TIntPrV WccSzCntV1; TSnap::GetWccSzCnt(Graph, WccSzCntV1); TFltPrV& WccSzCntV = DistrStatH.AddDat(gsdWcc); WccSzCntV.Gen(WccSzCntV1.Len(), 0); for (int i = 0; i < WccSzCntV1.Len(); i++) WccSzCntV.Add(TFltPr(WccSzCntV1[i].Val1(), WccSzCntV1[i].Val2())); } if (StatFSet.In(gsdScc)) { printf("scc "); TIntPrV SccSzCntV1; TSnap::GetSccSzCnt(Graph, SccSzCntV1); TFltPrV& SccSzCntV = DistrStatH.AddDat(gsdScc); SccSzCntV.Gen(SccSzCntV1.Len(), 0); for (int i = 0; i < SccSzCntV1.Len(); i++) SccSzCntV.Add(TFltPr(SccSzCntV1[i].Val1(), SccSzCntV1[i].Val2())); } if (StatFSet.In(gsdWcc) || StatFSet.In(gsdScc)) { printf("\n"); } }
void TGStat::TakeDegDistr | ( | const PGraph & | Graph | ) |
Definition at line 286 of file gstat.h.
References gsdInDeg, and gsdOutDeg.
Referenced by TakeStat().
{ TakeDegDistr(Graph, TFSet() | gsdInDeg | gsdOutDeg); }
void TGStat::TakeDegDistr | ( | const PGraph & | Graph, |
TFSet | StatFSet | ||
) |
Definition at line 291 of file gstat.h.
References THash< TKey, TDat, THashFunc >::AddDat(), DistrStatH, TSnap::GetInDegCnt(), TSnap::GetOutDegCnt(), gsdInDeg, gsdOutDeg, and TFSet::In().
{ // degree distribution if (StatFSet.In(gsdOutDeg) || StatFSet.In(gsdOutDeg)) { printf("deg "); } if (StatFSet.In(gsdInDeg)) { printf(" in "); TFltPrV& InDegV = DistrStatH.AddDat(gsdInDeg); TSnap::GetInDegCnt(Graph, InDegV); } if (StatFSet.In(gsdOutDeg)) { printf(" out "); TFltPrV& OutDegV = DistrStatH.AddDat(gsdOutDeg); TSnap::GetOutDegCnt(Graph, OutDegV); } if (StatFSet.In(gsdOutDeg) || StatFSet.In(gsdOutDeg)) { printf("\n"); } }
void TGStat::TakeDiam | ( | const PGraph & | Graph, |
const bool & | IsMxWcc = false |
||
) |
Definition at line 310 of file gstat.h.
References gsdHops, gsdWccHops, gsvEffDiam, gsvEffWccDiam, and gsvFullDiam.
Referenced by TakeStat().
{ TakeDiam(Graph, TFSet() | gsvFullDiam | gsvEffDiam | gsdHops | gsvEffWccDiam| gsdWccHops, IsMxWcc); }
void TGStat::TakeDiam | ( | const PGraph & | Graph, |
TFSet | StatFSet, | ||
const bool & | IsMxWcc = false |
||
) |
Definition at line 316 of file gstat.h.
References TMom::Add(), THash< TKey, TDat, THashFunc >::AddDat(), TSnap::TSnapDetail::CalcEffDiam(), TMom::Def(), DistrStatH, TVec< TVal >::Gen(), TSnap::GetAnf(), TSnap::GetBfsFullDiam(), TMom::GetMean(), TMom::GetSDev(), TExeTm::GetTmStr(), gsdHops, gsdWccHops, gsvEffDiam, gsvEffDiamDev, gsvEffWccDiam, gsvEffWccDiamDev, gsvFullDiam, gsvFullDiamDev, TFSet::In(), TVec< TVal >::Len(), NDiamRuns, SetVal(), and TExeTm::Tick().
{ TExeTm ExeTm; if (! IsMxWcc) { if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops)) { printf("ANF diam %d runs ", NDiamRuns); } bool Line=false; if (StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops)) { TMom DiamMom; ExeTm.Tick(); TIntFltKdV DistNbrsV; for (int r = 0; r < NDiamRuns; r++) { TSnap::GetAnf(Graph, DistNbrsV, -1, false, 32); DiamMom.Add(TSnap::TSnapDetail::CalcEffDiam(DistNbrsV, 0.9)); printf("."); } DiamMom.Def(); SetVal(gsvEffDiam, DiamMom.GetMean()); SetVal(gsvEffDiamDev, DiamMom.GetSDev()); TFltPrV& HopsV = DistrStatH.AddDat(gsdHops); HopsV.Gen(DistNbrsV.Len(), 0); for (int i = 0; i < DistNbrsV.Len(); i++) { HopsV.Add(TFltPr(DistNbrsV[i].Key(), DistNbrsV[i].Dat)); } printf(" ANF-eff %.1f[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); Line=true; } if (Line) { printf("\n"); } } else { if (StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops)) { printf("wcc diam "); } bool Line=false; if (StatFSet.In(gsvFullDiam)) { TMom DiamMom; ExeTm.Tick(); for (int r = 0; r < NDiamRuns; r++) { DiamMom.Add(TSnap::GetBfsFullDiam(Graph, 1, false)); printf("."); } DiamMom.Def(); SetVal(gsvFullDiam, DiamMom.GetMean()); SetVal(gsvFullDiamDev, DiamMom.GetSDev()); printf(" BFS-full %g[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); Line=true; } if (StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops)) { TMom DiamMom; ExeTm.Tick(); TIntFltKdV DistNbrsV; for (int r = 0; r < NDiamRuns; r++) { TSnap::GetAnf(Graph, DistNbrsV, -1, false, 32); DiamMom.Add(TSnap::TSnapDetail::CalcEffDiam(DistNbrsV, 0.9)); printf("."); } DiamMom.Def(); SetVal(gsvEffWccDiam, DiamMom.GetMean()); SetVal(gsvEffWccDiamDev, DiamMom.GetSDev()); TFltPrV& WccHopsV = DistrStatH.AddDat(gsdWccHops); WccHopsV.Gen(DistNbrsV.Len(), 0); for (int i = 0; i < DistNbrsV.Len(); i++) { WccHopsV.Add(TFltPr(DistNbrsV[i].Key(), DistNbrsV[i].Dat)); } printf(" ANF-wccEff %.1f[%s]", DiamMom.GetMean(), ExeTm.GetTmStr()); Line=true; } if (Line) { printf("\n"); } } }
void TGStat::TakeSpectral | ( | const PNGraph & | Graph, |
const int | _TakeSngVals = -1 |
||
) |
Definition at line 128 of file gstat.cpp.
References gsdSngVal, and gsdSngVec.
Referenced by TakeStat().
{ TakeSpectral(Graph, TFSet() | gsdSngVal | gsdSngVec, _TakeSngVals); }
void TGStat::TakeSpectral | ( | const PNGraph & | Graph, |
TFSet | StatFSet, | ||
int | _TakeSngVals = -1 |
||
) |
Definition at line 132 of file gstat.cpp.
References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), DistrStatH, TVec< TVal >::Gen(), TNGraph::GetNodes(), TSnap::GetSngVals(), TSnap::GetSngVec(), gsdSngVal, gsdSngVec, TFSet::In(), Kilo, TVec< TVal >::Len(), TMath::Mn(), TVec< TVal >::Sort(), and TakeSngVals.
{ if (_TakeSngVals == -1) { _TakeSngVals = TakeSngVals; } // singular values, vectors if (StatFSet.In(gsdSngVal)) { const int SngVals = TMath::Mn(_TakeSngVals, Graph->GetNodes()/2); TFltV SngValV1; TSnap::GetSngVals(Graph, SngVals, SngValV1); SngValV1.Sort(false); TFltPrV& SngValV = DistrStatH.AddDat(gsdSngVal); SngValV.Gen(SngValV1.Len(), 0); for (int i = 0; i < SngValV1.Len(); i++) { SngValV.Add(TFltPr(i+1, SngValV1[i])); } } if (StatFSet.In(gsdSngVec)) { TFltV LeftV, RightV; TSnap::GetSngVec(Graph, LeftV, RightV); LeftV.Sort(false); TFltPrV& SngVec = DistrStatH.AddDat(gsdSngVec); SngVec.Gen(LeftV.Len(), 0); for (int i = 0; i < TMath::Mn(Kilo(10), LeftV.Len()/2); i++) { if (LeftV[i] > 0) { SngVec.Add(TFltPr(i+1, LeftV[i])); } } } }
void TGStat::TakeStat | ( | const PNGraph & | Graph, |
const TSecTm & | Time, | ||
TFSet | StatFSet, | ||
const TStr & | GraphName | ||
) |
Definition at line 101 of file gstat.cpp.
References TNGraph::GetEdges(), TSnap::GetMxWcc(), TNGraph::GetNodes(), GraphNm, gsdClustCf, gsdTriadPart, gsdWcc, gsdWccHops, gsvClustCf, gsvEffWccDiam, gsvFullDiam, gsvNone, TFSet::In(), TakeBasicStat(), TakeClustCf(), TakeConnComp(), TakeDegDistr(), TakeDiam(), TakeSpectral(), TakeTriadPart(), and Time.
Referenced by TGStat().
{ printf("\n===TakeStat: G(%u, %u)\n", Graph->GetNodes(), Graph->GetEdges()); TExeTm ExeTm, FullTm; Time = _Time; GraphNm = GraphName; if (StatFSet.In(gsvNone)) { return; } TakeBasicStat(Graph, false); TakeDiam(Graph, StatFSet, false); if (StatFSet.In(gsdWcc) || StatFSet.In(gsdWccHops) || StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffWccDiam)) { PNGraph WccGraph = TSnap::GetMxWcc(Graph); TakeBasicStat(WccGraph, true); TakeDiam(WccGraph, StatFSet, true); } // degrees TakeDegDistr(Graph, StatFSet); // components TakeConnComp(Graph, StatFSet); // spectral TakeSpectral(Graph, StatFSet, -1); // clustering coeffient if (StatFSet.In(gsdClustCf) || StatFSet.In(gsvClustCf)) { TakeClustCf(Graph); } if (StatFSet.In(gsdTriadPart)) { TakeTriadPart(Graph); } printf(" [%s]\n", FullTm.GetTmStr()); }
void TGStat::TakeStat | ( | const PGraph & | Graph, |
const TSecTm & | Time, | ||
TFSet | StatFSet, | ||
const TStr & | GraphName | ||
) |
Definition at line 209 of file gstat.h.
References TSnap::GetMxWcc(), GraphNm, gsdClustCf, gsdHops, gsdScc, gsdTriadPart, gsdWcc, gsdWccHops, gsvClustCf, gsvEffDiam, gsvEffWccDiam, gsvFullDiam, gsvNone, TFSet::In(), TakeBasicStat(), TakeClustCf(), TakeConnComp(), TakeDegDistr(), TakeDiam(), TakeSpectral(), and TakeTriadPart().
{ printf("**TakeStat: G(%u, %u)\n", Graph->GetNodes(), Graph->GetEdges()); TExeTm ExeTm, FullTm; Time = _Time; GraphNm = GraphName; if (StatFSet.In(gsvNone)) { return; } TakeBasicStat(Graph, false); if (StatFSet.In(gsdWcc)) { TakeBasicStat(TSnap::GetMxWcc(Graph), true); } // degrees TakeDegDistr(Graph, StatFSet); if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffDiam) || StatFSet.In(gsdHops) || StatFSet.In(gsvEffWccDiam) || StatFSet.In(gsdWccHops) || StatFSet.In(gsdWcc) || StatFSet.In(gsdScc) || StatFSet.In(gsdClustCf) || StatFSet.In(gsvClustCf) || StatFSet.In(gsdTriadPart)) { PNGraph NGraph = TSnap::ConvertGraph<PNGraph>(Graph, true); // diameter TakeDiam(NGraph, StatFSet, false); // components TakeConnComp(NGraph, StatFSet); // spectral TakeSpectral(NGraph, StatFSet, -1); // clustering coeffient if (StatFSet.In(gsdClustCf) || StatFSet.In(gsvClustCf)) { TakeClustCf(NGraph); } if (StatFSet.In(gsdTriadPart)) { TakeTriadPart(NGraph); } if (StatFSet.In(gsvFullDiam) || StatFSet.In(gsvEffWccDiam)) { TakeDiam(TSnap::GetMxWcc(NGraph), StatFSet, true); } printf(" [%s]\n", FullTm.GetTmStr()); } }
void TGStat::TakeTriadPart | ( | const PGraph & | Graph | ) |
Definition at line 417 of file gstat.h.
References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), DistrStatH, TVec< TVal >::Gen(), TSnap::GetTriadParticip(), gsdTriadPart, and TVec< TVal >::Len().
Referenced by TakeStat().
{ printf("triadParticip "); TFltPrV& TriadCntV = DistrStatH.AddDat(gsdTriadPart); TIntPrV CntV; TSnap::GetTriadParticip(Graph, CntV); TriadCntV.Gen(CntV.Len(), 0); for (int i = 0; i < CntV.Len(); i++) { TriadCntV.Add(TFltPr(CntV[i].Val1(), CntV[i].Val2())); } }
TCRef TGStat::CRef [private] |
Definition at line 57 of file gstat.h.
Referenced by GetDistr(), GetDistrs(), HasDistr(), operator=(), operator==(), Save(), SetDistr(), TakeClustCf(), TakeConnComp(), TakeDegDistr(), TakeDiam(), TakeSpectral(), and TakeTriadPart().
const TFltPrV TGStat::EmptyV = TFltPrV() [static, private] |
Definition at line 51 of file gstat.h.
Referenced by GetDistr().
Definition at line 55 of file gstat.h.
Referenced by AvgGStat(), GetNm(), New(), operator=(), Save(), SetNm(), and TakeStat().
int TGStat::NDiamRuns = 10 [static] |
Definition at line 37 of file gstat.h.
Referenced by TFfGGen::GenFFGraphs(), TakeDiam(), and TTimeNENet::TimeGrowth().
int TGStat::TakeSngVals = 100 [static] |
Definition at line 38 of file gstat.h.
Referenced by TakeSpectral().
Definition at line 54 of file gstat.h.
Referenced by AvgGStat(), GetVal(), HasVal(), TGStat::TCmpByVal::operator()(), operator<(), operator=(), operator==(), Save(), and TakeStat().
Definition at line 56 of file gstat.h.
Referenced by GetVal(), GetVals(), HasVal(), operator<(), operator=(), operator==(), Save(), and SetVal().