14 else {
return ! Res; }
18 return operator()(*GS1, *GS2);
26 TakeStat(Graph, GraphTm, StatFSet, GraphName);
30 TakeStat(Graph, GraphTm, StatFSet, GraphName);
34 TakeStat(Graph, GraphTm, StatFSet, GraphName);
37 ValStatH(GStat.ValStatH), DistrStatH(GStat.DistrStatH) {
62 if (
Time<GStat.
Time) {
return true; }
63 if (
Time>GStat.
Time) {
return false; }
76 if (StatVal ==
gsvIndex) {
return true; }
82 if (StatVal ==
gsvIndex) {
return -1; }
134 printf(
"**[%s]\n", FullTm.GetTmStr());
166 printf(
"**[%s]\n", FullTm.GetTmStr());
175 if (_TakeSngVals == -1) { _TakeSngVals =
TakeSngVals; }
178 printf(
"sing-vals...");
182 SngValV1.Sort(
false);
184 SngValV.
Gen(SngValV1.Len(), 0);
185 for (
int i = 0; i < SngValV1.Len(); i++) {
191 printf(
"sing-vec...");
196 SngVec.
Gen(LeftV.
Len(), 0);
198 if (LeftV[i] > 0) { SngVec.
Add(
TFltPr(i+1, LeftV[i])); }
223 if (! FSet.
In(Distr)) {
continue; }
224 Plot(Distr, FNmPref, Desc, PowerFit);
231 Plot(Distr, FNmPref, Desc, PowerFit);
238 if (!
HasVal(Val)) {
continue; }
244 AvgGStat(GStatVec->GetGStatV(), ClipAt1);
248 if (GStatV.
Empty())
return;
249 Time = GStatV[0]->Time;
252 for (
int statVal = 0; statVal >
gsvMx; statVal++) {
255 for (
int i = 0; i < GStatV.
Len(); i++) {
256 if (GStatV[i]->
HasVal(GStatVal)) {
270 for (
int i = 0; i < GStatV.
Len(); i++) {
271 if (GStatV[i]->
HasDistr(GStatDistr)) {
272 const TFltPrV& D = GStatV[i]->GetDistr(GStatDistr);
273 for (
int d = 0; d < D.
Len(); d++) {
274 ValToSumH.
AddDat(D[d].Val1) += D[d].Val2; }
278 IAssert(DistrCnt==0 || DistrCnt==GStatV.
Len());
281 for (
int i = 0; i < AvgStatV.Len(); i++) {
282 AvgStatV[i].Val2 /= double(DistrCnt);
283 if (ClipAt1 && AvgStatV[i].Val2 < 1) { AvgStatV[i].Val2 = 1; }
294 case gsdWcc :
return "WccDist";
295 case gsdScc :
return "SccDist";
309 if (ValTyStrH.
Empty()) {
348 return ValTyStrH.
GetDat(
int(Val));
416 TmUnit(_TmUnit), StatFSet(TakeGrowthStat), GStatV() {
420 TmUnit(GStat.TmUnit), StatFSet(GStat.StatFSet), GStatV(GStat.GStatV) {
431 return new TGStatVec(_TmUnit, TakeGrowthStat);
441 if (
this != &GStat) {
461 printf(
" ** TGStatVec::Add: graph too small (%d nodes).SKIP\n", Graph->
GetNodes());
469 printf(
" ** TGStatVec::Add: graph too small (%d nodes).SKIP\n", Graph->
GetNodes());
477 printf(
" ** TGStatVec::Add: graph too small (%d nodes).SKIP\n", Graph->GetNodes());
489 for (
int i = 0; i <
Len(); i++) {
490 if (
At(i)->Time >= Tm) { NewTickV.
Add(
At(i)); }
497 for (
int i = 0; i <
Len(); i++) {
498 if (
At(i)->Time <= Tm) { NewTickV.
Add(
At(i)); }
505 for (
int i = 0; i <
Len(); i++) {
506 if (
At(i)->GetNodes() >= MinNodes) { NewTickV.
Add(
At(i)); }
514 for (
int t = 0; t <
Len(); t++) {
517 else { x =
At(t)->GetVal(XVal); }
525 Stat->AvgGStat(
GStatV, ClipAt1);
535 if (Desc.
Empty()) { Desc = OutFNm; }
540 Last()->GetNodes(),
Last()->GetEdges()));
552 if (SkipStat.
In(Stat)) {
continue; }
553 if (
Last()->HasVal(Stat) &&
Last()->HasVal(XVal) && Stat!=XVal) {
554 Plot(XVal, Stat, OutFNm, Desc, Scale, PowerFit);
560 const bool& PowerFit,
const TGpSeriesTy& PlotWith,
const TStr& Style)
const {
565 At(0)->GetNodes(),
At(0)->GetEdges(),
Last()->GetNodes(),
Last()->GetEdges()));
569 for (
int at = 0; at <
Len(); at++) {
570 TStr Legend =
At(at)->GetNm();
571 if (Legend.
Empty()) { Legend =
At(at)->GetTmStr(); }
573 plotId = GnuPlot.
AddPlot(
At(at)->GetDistr(Distr), PlotWith, Legend, Style); }
577 plotId = GnuPlot.
AddPlot(ExpBinV, PlotWith, Legend, Style);
585 FILE *F = fopen(
TStr::Fmt(
"growth.%s.tab", FNmPref.
CStr()).CStr(),
"wt");
586 fprintf(F,
"# %s\n", Desc.
CStr());
589 for (
int i = 0; i <
Len(); i++) {
595 for (
int sv = 0; sv < StatValV.
Len(); sv++) {
597 fprintf(F,
"Time\n");
598 for (
int i = 0; i <
Len(); i++) {
600 for (
int sv = 0; sv < StatValV.
Len(); sv++) {
static const T & Mn(const T &LVal, const T &RVal)
bool HasVal(const TGStatVal &Stat) const
PGStat GetAvgGStat(const bool &ClipAt1=false)
static const TFltPrV EmptyV
#define IAssertR(Cond, Reason)
static TStr GetValStr(const TGStatVal &Val)
void ImposeDistr(const TGStatDistr &Distr, const TStr &FNmPref, TStr Desc=TStr(), const bool &ExpBin=false, const bool &PowerFit=false, const TGpSeriesTy &PlotWith=gpwLinesPoints, const TStr &Style="") const
static void MakeExpBins(const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
void SavePng(const int &SizeX=1000, const int &SizeY=800, const TStr &Comment=TStr())
PGraph GetMxWcc(const PGraph &Graph)
Returns a graph representing the largest weakly connected component on an input Graph.
void Save(TSOut &SOut) const
void TakeSpectral(const PNGraph &Graph, const int _TakeSngVals=-1)
void Save(TSOut &SOut) const
bool operator==(const TGStat &GStat) const
int GetEdges() const
Returns the number of edges in the graph.
static TFSet NoDiamStat()
enum TGStatDistr_ TGStatDistr
int GetEdges() const
Returns the number of edges in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
void TakeConnComp(const PGraph &Graph)
void Save(TSOut &SOut) const
void PlotAllVsX(const TGStatVal &XVal, const TStr &OutFNm, TStr Desc=TStr(), const TGpScaleTy &Scale=gpsAuto, const bool &PowerFit=false) const
static TFSet NoDistrStat()
void GetKeyV(TVec< TKey > &KeyV) const
int GetNodes() const
Returns the number of nodes in the graph.
void AvgGStat(const PGStatVec &GStatVec, const bool &ClipAt1=false)
void SetXYLabel(const TStr &XLabel, const TStr &YLabel)
TGStatVec & operator=(const TGStatVec &GStat)
static TStr GetDistrStr(const TGStatDistr &Distr)
const TDat & GetDat(const TKey &Key) const
bool HasDistr(const TGStatDistr &Distr) const
void Sort(const TGStatVal &SortBy=gsvNodes, const bool &Asc=true)
bool HasDistr(const TGStatDistr &Stat) const
int AddPwrFit(const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const TStr &Style=TStr())
int GetNodes() const
Returns the number of nodes in the graph.
void Save(TSOut &SOut) const
void Save(TSOut &SOut) const
bool Empty() const
Tests whether the vector is empty.
enum TGStatVal_ TGStatVal
void SaveTxt(const TStr &FNmPref, const TStr &Desc) const
bool operator()(const TGStat &GS1, const TGStat &GS2) const
Graph Statistics Sequence.
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
int GetTime(const int &ValN) const
const char * GetTmStr() const
static TPlotInfo GetPlotInfo(const TGStatVal &Val)
void GetSngVec(const PNGraph &Graph, TFltV &LeftSV, TFltV &RightSV)
Computes the leading left and right singular vector of the adjacency matrix representing a directed G...
void Save(TSOut &SOut) const
void TakeStat(const PNGraph &Graph, const TSecTm &Time, TFSet StatFSet, const TStr &GraphName)
void TakeTriadPart(const PGraph &Graph)
void Add(const TFlt &Val, const TFlt &Wgt=1)
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
THash< TInt, TFltPrV > DistrStatH
Statistics of a Graph Snapshot.
void DelBefore(const TSecTm &Tm)
void Save(TSOut &SOut, const bool &IsSmall=false) const
void TakeClustCf(const PGraph &Graph, const int &SampleNodes=-1)
static PGStat New(const TSecTm &Time=TSecTm(), const TStr &GraphName=TStr())
void DelSmallNodes(const int &MinNodes)
bool HasVal(const TGStatVal &StatVal) const
void TakeBccStat(const PGraph &Graph, TFSet StatFSet)
int AddKey(const TKey &Key)
const TVal & Last() const
Returns a reference to the last element of the vector.
TGStatVec(const TTmUnit &_TmUnit=tmu1Sec)
static uint MinNodesEdges
TPair< TFlt, TFlt > TFltPr
void SaveEps(const int &FontSz=30, const TStr &Comment=TStr())
void SetVal(const TGStatVal &StatVal, const double &Val)
void Save(TSOut &SOut) const
void GetSngVals(const PNGraph &Graph, const int &SngVals, TFltV &SngValV)
Computes largest SngVals singular values of the adjacency matrix representing a directed Graph...
PGStat At(const int &ValN) const
void PlotAll(const TStr &FNmPref, TStr Desc=TStr(), bool PowerFit=false) const
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
void SetScale(const TGpScaleTy &GpScaleTy)
TStr GetStr(const TLoc &Loc=lUs) const
static TStr Fmt(const char *FmtStr,...)
TQuad< TStr, TStr, TStr, TGpScaleTy > TPlotInfo
void DelAfter(const TSecTm &Tm)
void GetValV(const TGStatVal &XVal, const TGStatVal &YVal, TFltPrV &ValV) const
void GetKeyDatPrV(TVec< TPair< TKey, TDat > > &KeyDatPrV) const
void Plot(const TGStatDistr &Distr, const TStr &FNmPref, TStr Desc=TStr(), bool PowerFit=false) const
TGStat & operator=(const TGStat &GStat)
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
TGStat(const TSecTm &GraphTm=TSecTm(), const TStr &GraphName=TStr())
void TakeSccStat(const PGraph &Graph, TFSet StatFSet)
double GetVal(const TGStatVal &StatVal) const
void SortCmp(const TCmp &Cmp)
Sorts the elements of the vector using the comparator Cmp.
bool IsKey(const TKey &Key) const
static PGStatVec New(const TTmUnit &_TmUnit=tmu1Sec)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void SetDistr(const TGStatDistr &Distr, const TFltPrV &FltPrV)
TDat & AddDat(const TKey &Key)
void Plot(const TGStatVal &XVal, const TGStatVal &YVal, const TStr &OutFNm, TStr &Desc, const TGpScaleTy &Scale=gpsAuto, const bool &PowerFit=false) const
bool operator<(const TGStat &GStat) const
const TFltPrV & GetDistr(const TGStatDistr &Distr) const
Vector is a sequence TVal objects representing an array that can change in size.
void TakeDegDistr(const PGraph &Graph)
void TakeBasicStat(const PGraph &Graph, const bool &IsMxWcc=false)
void TakeDiam(const PGraph &Graph, const bool &IsMxWcc=false)
bool In(const int &FlagN) const