| 
    SNAP Library 2.0, Developer Reference
    2013-05-13 16:33:57
    
   SNAP, a general purpose, high performance system for analysis and manipulation of large networks 
   | 
  
  
  
 
Graph Statistics Sequence. More...
#include <gstat.h>

Public Member Functions | |
| TGStatVec (const TTmUnit &_TmUnit=tmu1Sec) | |
| TGStatVec (const TTmUnit &_TmUnit, const TFSet &TakeGrowthStat) | |
| TGStatVec (const TGStatVec &GStat) | |
| TGStatVec (TSIn &SIn) | |
| void | Save (TSOut &SOut) const | 
| TGStatVec & | operator= (const TGStatVec &GStat) | 
| PGStat | Add () | 
| PGStat | Add (const TSecTm &Time, TStr GraphNm=TStr()) | 
| void | Add (const PGStat &Growth) | 
| void | Add (const PNGraph &Graph, const TSecTm &Time, const TStr &GraphNm=TStr()) | 
| void | Add (const PNEGraph &Graph, const TSecTm &Time, const TStr &GraphNm=TStr()) | 
| void | Clr () | 
| void | Sort (const TGStatVal &SortBy=gsvNodes, const bool &Asc=true) | 
| int | Len () const | 
| bool | Empty () const | 
| PGStat | operator[] (const int &ValN) const | 
| PGStat | At (const int &ValN) const | 
| PGStat | Last () const | 
| const TGStatV & | GetGStatV () const | 
| void | Del (const int &ValN) | 
| void | DelLast () | 
| void | DelBefore (const TSecTm &Tm) | 
| void | DelAfter (const TSecTm &Tm) | 
| void | DelSmallNodes (const int &MinNodes) | 
| void | SetTmUnit (const TTmUnit &TimeUnit) | 
| TTmUnit | GetTmUnit () const | 
| void | SetTakeStat (const TFSet &TakeStatSet) | 
| bool | HasVal (const TGStatVal &Stat) const | 
| bool | HasDistr (const TGStatDistr &Stat) const | 
| void | GetValV (const TGStatVal &XVal, const TGStatVal &YVal, TFltPrV &ValV) const | 
| PGStat | GetAvgGStat (const bool &ClipAt1=false) | 
| void | Plot (const TGStatVal &XVal, const TGStatVal &YVal, const TStr &OutFNm, TStr &Desc, const TGpScaleTy &Scale=gpsAuto, const bool &PowerFit=false) const | 
| void | PlotAllVsX (const TGStatVal &XVal, const TStr &OutFNm, TStr Desc=TStr(), const TGpScaleTy &Scale=gpsAuto, const bool &PowerFit=false) const | 
| 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 | 
| void | SaveTxt (const TStr &FNmPref, const TStr &Desc) const | 
Static Public Member Functions | |
| static PGStatVec | New (const TTmUnit &_TmUnit=tmu1Sec) | 
| static PGStatVec | New (const TTmUnit &_TmUnit, const TFSet &TakeGrowthStat) | 
| static PGStatVec | Load (TSIn &SIn) | 
Static Public Attributes | |
| static uint | MinNodesEdges = 10 | 
Private Attributes | |
| TCRef | CRef | 
| TTmUnit | TmUnit | 
| TFSet | StatFSet | 
| TGStatV | GStatV | 
Friends | |
| class | TPt< TGStatVec > | 
| TGStatVec::TGStatVec | ( | const TTmUnit & | _TmUnit = tmu1Sec | ) | 
| TGStatVec::TGStatVec | ( | const TTmUnit & | _TmUnit, | 
| const TFSet & | TakeGrowthStat | ||
| ) | 
| TGStatVec::TGStatVec | ( | const TGStatVec & | GStat | ) | 
| TGStatVec::TGStatVec | ( | TSIn & | SIn | ) | 
| PGStat TGStatVec::Add | ( | ) | 
Definition at line 396 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), GStatV, TVec< TVal, TSizeTy >::Last(), and TGStat::New().
Referenced by Add(), and TMAGFitBern::PlotProperties().
                      {
  GStatV.Add(TGStat::New());
  return GStatV.Last();
}


| PGStat TGStatVec::Add | ( | const TSecTm & | Time, | 
| TStr | GraphNm = TStr()  | 
        ||
| ) | 
Definition at line 401 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), GStatV, TVec< TVal, TSizeTy >::Last(), and TGStat::New().
                                                      {
  GStatV.Add(TGStat::New(Time, GraphNm));
  return GStatV.Last();
}

| void TGStatVec::Add | ( | const PGStat & | Growth | ) |  [inline] | 
        
| void TGStatVec::Add | ( | const PNGraph & | Graph, | 
| const TSecTm & | Time, | ||
| const TStr & | GraphNm = TStr()  | 
        ||
| ) | 
Definition at line 406 of file gstat.cpp.
References Add(), TNGraph::GetNodes(), MinNodesEdges, TGStat::New(), and StatFSet.
                                                                                 {
  if (Graph->GetNodes() < (int) TGStatVec::MinNodesEdges) {
    printf(" ** TGStatVec::Add: graph too small (%d nodes).SKIP\n", Graph->GetNodes());
    return;
  }
  Add(TGStat::New(Graph, Time, StatFSet, GraphNm));
}

| void TGStatVec::Add | ( | const PNEGraph & | Graph, | 
| const TSecTm & | Time, | ||
| const TStr & | GraphNm = TStr()  | 
        ||
| ) | 
Definition at line 414 of file gstat.cpp.
References Add(), MinNodesEdges, TGStat::New(), and StatFSet.
                                                                                  {
  if (Graph->GetNodes() < (int) TGStatVec::MinNodesEdges) {
    printf(" ** TGStatVec::Add: graph too small (%d nodes).SKIP\n", Graph->GetNodes());
    return;
  }
  Add(TGStat::New(Graph, Time, StatFSet, GraphNm));
}

| PGStat TGStatVec::At | ( | const int & | ValN | ) |  const [inline] | 
        
Definition at line 177 of file gstat.h.
References GStatV.
Referenced by DelAfter(), DelBefore(), DelSmallNodes(), GetValV(), ImposeDistr(), TMAGFitBern::PlotProperties(), and SaveTxt().
{ return GStatV[ValN]; }

| void TGStatVec::Clr | ( | ) |  [inline] | 
        
| void TGStatVec::Del | ( | const int & | ValN | ) |  [inline] | 
        
| void TGStatVec::DelAfter | ( | const TSecTm & | Tm | ) | 
Definition at line 434 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), At(), GStatV, Len(), and TVec< TVal, TSizeTy >::Swap().
                                         {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->Time <= Tm) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

| void TGStatVec::DelBefore | ( | const TSecTm & | Tm | ) | 
Definition at line 426 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), At(), GStatV, Len(), and TVec< TVal, TSizeTy >::Swap().
                                          {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->Time >= Tm) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

| void TGStatVec::DelLast | ( | ) |  [inline] | 
        
| void TGStatVec::DelSmallNodes | ( | const int & | MinNodes | ) | 
Definition at line 442 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), At(), GStatV, Len(), and TVec< TVal, TSizeTy >::Swap().
                                                 {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->GetNodes() >= MinNodes) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

| bool TGStatVec::Empty | ( | ) |  const [inline] | 
        
| PGStat TGStatVec::GetAvgGStat | ( | const bool & | ClipAt1 = false | ) | 
| const TGStatV& TGStatVec::GetGStatV | ( | ) |  const [inline] | 
        
| TTmUnit TGStatVec::GetTmUnit | ( | ) |  const [inline] | 
        
| void TGStatVec::GetValV | ( | const TGStatVal & | XVal, | 
| const TGStatVal & | YVal, | ||
| TFltPrV & | ValV | ||
| ) | const | 
Definition at line 450 of file gstat.cpp.
References TVec< TVal, TSizeTy >::Add(), At(), TVec< TVal, TSizeTy >::Gen(), gsvTime, and Len().
Referenced by Plot().
                                                                                         {
  ValV.Gen(Len(), 0);
  double x;
  for (int t = 0; t < Len(); t++) {
    if (XVal == gsvTime) { x = t+1; }
    else { x = At(t)->GetVal(XVal); }
    ValV.Add(TFltPr(x, At(t)->GetVal(YVal)));
  }
}


| bool TGStatVec::HasDistr | ( | const TGStatDistr & | Stat | ) |  const [inline] | 
        
Definition at line 191 of file gstat.h.
References TFSet::In(), and StatFSet.
Referenced by ImposeDistr().


| bool TGStatVec::HasVal | ( | const TGStatVal & | Stat | ) |  const [inline] | 
        
| void TGStatVec::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 | 
Definition at line 496 of file gstat.cpp.
References TGnuPlot::AddPlot(), TGnuPlot::AddPwrFit(), At(), TStr::CStr(), TStr::Empty(), TStr::Fmt(), TStr::GetUc(), gpwLines, gsdMx, gsdUndef, HasDistr(), Last(), Len(), TGnuPlot::MakeExpBins(), 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.
                                                                                {
  if (Desc.Empty()) Desc = FNmPref.GetUc();
  if (! At(0)->HasDistr(Distr) || Distr==gsdUndef || Distr==gsdMx) { return; }
  TGStat::TPlotInfo Info = At(0)->GetPlotInfo(Distr);
  TGnuPlot GnuPlot(Info.Val1+TStr(".")+FNmPref, TStr::Fmt("%s. G(%d, %d) --> G(%d, %d)", Desc.CStr(),
    At(0)->GetNodes(), At(0)->GetEdges(), Last()->GetNodes(), Last()->GetEdges()));
  GnuPlot.SetXYLabel(Info.Val2, Info.Val3);
  GnuPlot.SetScale(Info.Val4);
  int plotId;
  for (int at = 0; at < Len(); at++) {
    TStr Legend = At(at)->GetNm();
    if (Legend.Empty()) { Legend = At(at)->GetTmStr(); }
    if (! ExpBin) { 
      plotId = GnuPlot.AddPlot(At(at)->GetDistr(Distr), PlotWith, Legend, Style); }
    else { 
      TFltPrV ExpBinV; 
      TGnuPlot::MakeExpBins(At(at)->GetDistr(Distr), ExpBinV, 2, 0);
      plotId = GnuPlot.AddPlot(ExpBinV, PlotWith, Legend, Style);
    }
    if (PowerFit) { GnuPlot.AddPwrFit(plotId, gpwLines); }
  }
  GnuPlot.SavePng();
}

| PGStat TGStatVec::Last | ( | ) |  const [inline] | 
        
Definition at line 178 of file gstat.h.
References GStatV, and TVec< TVal, TSizeTy >::Last().
Referenced by ImposeDistr(), Plot(), and PlotAllVsX().


| int TGStatVec::Len | ( | ) |  const [inline] | 
        
Definition at line 174 of file gstat.h.
References GStatV, and TVec< TVal, TSizeTy >::Len().
Referenced by DelAfter(), DelBefore(), DelSmallNodes(), GetValV(), ImposeDistr(), TMAGFitBern::PlotProperties(), and SaveTxt().


| static PGStatVec TGStatVec::Load | ( | TSIn & | SIn | ) |  [inline, static] | 
        
Definition at line 161 of file gstat.h.
References TGStatVec().
{ return new TGStatVec(SIn); }

| PGStatVec TGStatVec::New | ( | const TTmUnit & | _TmUnit = tmu1Sec | ) |  [static] | 
        
Definition at line 373 of file gstat.cpp.
References TGStatVec().
Referenced by TFfGGen::GenFFGraphs(), and GetAvgGStat().
                                               {
  return new TGStatVec(_TmUnit);
}


| PGStatVec TGStatVec::New | ( | const TTmUnit & | _TmUnit, | 
| const TFSet & | TakeGrowthStat | ||
| ) |  [static] | 
        
Definition at line 377 of file gstat.cpp.
References TGStatVec().
                                                                            {
  return new TGStatVec(_TmUnit, TakeGrowthStat);
}

| PGStat TGStatVec::operator[] | ( | const int & | ValN | ) |  const [inline] | 
        
| void TGStatVec::Plot | ( | const TGStatVal & | XVal, | 
| const TGStatVal & | YVal, | ||
| const TStr & | OutFNm, | ||
| TStr & | Desc, | ||
| const TGpScaleTy & | Scale = gpsAuto,  | 
        ||
| const bool & | PowerFit = false  | 
        ||
| ) | const | 
Definition at line 466 of file gstat.cpp.
References TGnuPlot::AddPlot(), TGnuPlot::AddPwrFit(), TStr::CStr(), TStr::Empty(), TStr::Fmt(), TGStat::GetValStr(), GetValV(), gpwLinesPoints, HasVal(), Last(), TGnuPlot::SavePng(), TGnuPlot::SetScale(), and TGnuPlot::SetXYLabel().
Referenced by PlotAllVsX().
                                                                                                                                                     {
  if (! Last()->HasVal(XVal) || ! Last()->HasVal(YVal)) {
    if (! Last()->HasVal(XVal)) { printf("** Does not have %s statistic\n", TGStat::GetValStr(XVal).CStr()); }
    if (! Last()->HasVal(YVal)) { printf("** Does not have %s statistic\n", TGStat::GetValStr(YVal).CStr()); }
    return;
  }
  if (Desc.Empty()) { Desc = OutFNm; }
  TFltPrV ValV;
  TGStatVec::GetValV(XVal, YVal, ValV);
  TGnuPlot GP(TStr::Fmt("%s-%s.%s", TGStat::GetValStr(XVal).CStr(), TGStat::GetValStr(YVal).CStr(), OutFNm.CStr()),
    TStr::Fmt("%s. %s vs. %s. G(%d,%d)", Desc.CStr(), TGStat::GetValStr(XVal).CStr(), TGStat::GetValStr(YVal).CStr(),
    Last()->GetNodes(), Last()->GetEdges()));
  GP.SetScale(Scale);
  GP.SetXYLabel(TGStat::GetValStr(XVal), TGStat::GetValStr(YVal));
  const int Id = GP.AddPlot(ValV, gpwLinesPoints);
  if (PowerFit) { GP.AddPwrFit(Id); }
  GP.SavePng();
}


| void TGStatVec::PlotAllVsX | ( | const TGStatVal & | XVal, | 
| const TStr & | OutFNm, | ||
| TStr | Desc = TStr(),  | 
        ||
| const TGpScaleTy & | Scale = gpsAuto,  | 
        ||
| const bool & | PowerFit = false  | 
        ||
| ) | const | 
Definition at line 485 of file gstat.cpp.
References gsvEffDiamDev, gsvEffWccDiamDev, gsvFullDiamDev, gsvFullWccDiamDev, gsvMx, gsvNone, TFSet::In(), Last(), and Plot().
                                                                                                                                    {
  const TFSet SkipStat = TFSet() | gsvFullDiamDev | gsvEffDiamDev | gsvEffWccDiamDev | gsvFullWccDiamDev;
  for (int stat = gsvNone; stat < gsvMx; stat++) {
    const TGStatVal Stat = TGStatVal(stat);
    if (SkipStat.In(Stat)) { continue; }
    if (Last()->HasVal(Stat) && Last()->HasVal(XVal) && Stat!=XVal) {
      Plot(XVal, Stat, OutFNm, Desc, Scale, PowerFit);
    }
  }
}

| void TGStatVec::Save | ( | TSOut & | SOut | ) | const | 
Definition at line 381 of file gstat.cpp.
References GStatV, TFSet::Save(), TVec< TVal, TSizeTy >::Save(), TInt::Save(), StatFSet, and TmUnit.

| void TGStatVec::SaveTxt | ( | const TStr & | FNmPref, | 
| const TStr & | Desc | ||
| ) | const | 
Definition at line 521 of file gstat.cpp.
References THashSet< TKey, THashFunc >::AddKey(), At(), TStr::CStr(), TStr::Fmt(), THashSet< TKey, THashFunc >::GetKeyV(), TGStat::GetTmStr(), TTmInfo::GetTmUnitStr(), TGStat::GetVal(), TGStat::GetValStr(), gsvMx, gsvNone, Len(), TVec< TVal, TSizeTy >::Len(), TVec< TVal, TSizeTy >::Sort(), and TmUnit.
                                                                   {
  FILE *F = fopen(TStr::Fmt("growth.%s.tab", FNmPref.CStr()).CStr(), "wt");
  fprintf(F, "# %s\n", Desc.CStr());
  fprintf(F, "# %s", TTmInfo::GetTmUnitStr(TmUnit).CStr());
  TIntSet StatValSet;
  for (int i = 0; i < Len(); i++) {
    for (int v = gsvNone; v < gsvMx; v++) {
      if (At(i)->HasVal(TGStatVal(v))) { StatValSet.AddKey(v); }
    }
  }
  TIntV StatValV;  StatValSet.GetKeyV(StatValV);  StatValV.Sort();
  for (int sv = 0; sv < StatValV.Len(); sv++) {
    fprintf(F, "\t%s", TGStat::GetValStr(TGStatVal(StatValV[sv].Val)).CStr()); }
  fprintf(F, "Time\n");
  for (int i = 0; i < Len(); i++) {
    const TGStat& G = *At(i);
    for (int sv = 0; sv < StatValV.Len(); sv++) {
      fprintf(F, "%g\t", G.GetVal(TGStatVal(StatValV[sv].Val))); }
    fprintf(F, "%s\n", G.GetTmStr().CStr());
  }
  fclose(F);
}

| void TGStatVec::SetTakeStat | ( | const TFSet & | TakeStatSet | ) |  [inline] | 
        
| void TGStatVec::SetTmUnit | ( | const TTmUnit & | TimeUnit | ) |  [inline] | 
        
| void TGStatVec::Sort | ( | const TGStatVal & | SortBy = gsvNodes,  | 
        
| const bool & | Asc = true  | 
        ||
| ) | 
Definition at line 422 of file gstat.cpp.
References GStatV, and TVec< TVal, TSizeTy >::SortCmp().
                                                             {
  GStatV.SortCmp(TGStat::TCmpByVal(SortBy, Asc));
}

TCRef TGStatVec::CRef [private] | 
        
TGStatV TGStatVec::GStatV [private] | 
        
Definition at line 154 of file gstat.h.
Referenced by Add(), At(), Clr(), Del(), DelAfter(), DelBefore(), DelLast(), DelSmallNodes(), Empty(), GetAvgGStat(), GetGStatV(), Last(), Len(), operator=(), operator[](), Save(), and Sort().
uint TGStatVec::MinNodesEdges = 10 [static] | 
        
TFSet TGStatVec::StatFSet [private] | 
        
Definition at line 153 of file gstat.h.
Referenced by Add(), HasDistr(), HasVal(), operator=(), Save(), SetTakeStat(), and TGStatVec().
TTmUnit TGStatVec::TmUnit [private] | 
        
Definition at line 152 of file gstat.h.
Referenced by GetTmUnit(), operator=(), Save(), SaveTxt(), and SetTmUnit().