SNAP Library 2.1, User Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TGStatVec Class Reference

Graph Statistics Sequence. More...

#include <gstat.h>

List of all members.

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
TGStatVecoperator= (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 PUNGraph &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 TGStatVGetGStatV () const
int GetTime (const int &ValN) 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 >

Detailed Description

Graph Statistics Sequence.

Definition at line 155 of file gstat.h.


Constructor & Destructor Documentation

TGStatVec::TGStatVec ( const TTmUnit _TmUnit = tmu1Sec)

Definition at line 411 of file gstat.cpp.

                                           : TmUnit(_TmUnit), StatFSet(), GStatV() {
  StatFSet = TGStat::AllStat();
}
TGStatVec::TGStatVec ( const TTmUnit _TmUnit,
const TFSet TakeGrowthStat 
)

Definition at line 415 of file gstat.cpp.

                                                                        :
   TmUnit(_TmUnit), StatFSet(TakeGrowthStat), GStatV() {
}
TGStatVec::TGStatVec ( const TGStatVec GStat)

Definition at line 419 of file gstat.cpp.

                                           :
  TmUnit(GStat.TmUnit), StatFSet(GStat.StatFSet), GStatV(GStat.GStatV) {
}

Definition at line 423 of file gstat.cpp.

                              : TmUnit((TTmUnit) TInt(SIn).Val), StatFSet(SIn), GStatV(SIn) {
}

Member Function Documentation

Definition at line 449 of file gstat.cpp.

                      {
  GStatV.Add(TGStat::New());
  return GStatV.Last();
}
PGStat TGStatVec::Add ( const TSecTm Time,
TStr  GraphNm = TStr() 
)

Definition at line 454 of file gstat.cpp.

                                                      {
  GStatV.Add(TGStat::New(Time, GraphNm));
  return GStatV.Last();
}
void TGStatVec::Add ( const PGStat Growth) [inline]

Definition at line 176 of file gstat.h.

{ GStatV.Add(Growth); }
void TGStatVec::Add ( const PNGraph Graph,
const TSecTm Time,
const TStr GraphNm = TStr() 
)

Definition at line 459 of file gstat.cpp.

                                                                                 {
  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 PUNGraph Graph,
const TSecTm Time,
const TStr GraphNm = TStr() 
)

Definition at line 467 of file gstat.cpp.

                                                                                  {
  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 475 of file gstat.cpp.

                                                                                  {
  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 186 of file gstat.h.

{ return GStatV[ValN]; }
void TGStatVec::Clr ( ) [inline]

Definition at line 180 of file gstat.h.

{ GStatV.Clr(); }
void TGStatVec::Del ( const int &  ValN) [inline]

Definition at line 191 of file gstat.h.

{ GStatV.Del(ValN); }
void TGStatVec::DelAfter ( const TSecTm Tm)

Definition at line 495 of file gstat.cpp.

                                         {
  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 487 of file gstat.cpp.

                                          {
  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]

Definition at line 192 of file gstat.h.

{ GStatV.DelLast(); }
void TGStatVec::DelSmallNodes ( const int &  MinNodes)

Definition at line 503 of file gstat.cpp.

                                                 {
  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]

Definition at line 184 of file gstat.h.

{ return GStatV.Empty(); }
PGStat TGStatVec::GetAvgGStat ( const bool &  ClipAt1 = false)

Definition at line 523 of file gstat.cpp.

                                                 {
  PGStat Stat = TGStat::New();
  Stat->AvgGStat(GStatV, ClipAt1);
  return Stat;
}
const TGStatV& TGStatVec::GetGStatV ( ) const [inline]

Definition at line 188 of file gstat.h.

{ return GStatV; }
int TGStatVec::GetTime ( const int &  ValN) const [inline]

Definition at line 189 of file gstat.h.

{ return At(ValN)->GetTime(TmUnit); }
TTmUnit TGStatVec::GetTmUnit ( ) const [inline]

Definition at line 198 of file gstat.h.

{ return TmUnit; }
void TGStatVec::GetValV ( const TGStatVal XVal,
const TGStatVal YVal,
TFltPrV ValV 
) const

Definition at line 511 of file gstat.cpp.

                                                                                         {
  ValV.Gen(Len(), 0);
  double x;
  for (int t = 0; t < Len(); t++) {
    if (XVal == gsvIndex) { x = t+1; }
    else if (XVal == gsvTime) { x = GetTime(t); }
    else { x = At(t)->GetVal(XVal); }
    ValV.Add(TFltPr(x, At(t)->GetVal(YVal)));
  }
  ValV.Sort(true); // sort by ascending x value
}
bool TGStatVec::HasDistr ( const TGStatDistr Stat) const [inline]

Definition at line 201 of file gstat.h.

{ return StatFSet.In(Stat); }
bool TGStatVec::HasVal ( const TGStatVal Stat) const [inline]

Definition at line 200 of file gstat.h.

{ return StatFSet.In(Stat); }
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 559 of file gstat.cpp.

                                                                                {
  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 187 of file gstat.h.

{ return GStatV.Last(); }
int TGStatVec::Len ( ) const [inline]

Definition at line 183 of file gstat.h.

{ return GStatV.Len(); }
static PGStatVec TGStatVec::Load ( TSIn SIn) [inline, static]

Definition at line 169 of file gstat.h.

{ return new TGStatVec(SIn); }
PGStatVec TGStatVec::New ( const TTmUnit _TmUnit = tmu1Sec) [static]

Definition at line 426 of file gstat.cpp.

                                               {
  return new TGStatVec(_TmUnit);
}
PGStatVec TGStatVec::New ( const TTmUnit _TmUnit,
const TFSet TakeGrowthStat 
) [static]

Definition at line 430 of file gstat.cpp.

                                                                            {
  return new TGStatVec(_TmUnit, TakeGrowthStat);
}
TGStatVec & TGStatVec::operator= ( const TGStatVec GStat)

Definition at line 440 of file gstat.cpp.

                                                        {
  if (this != &GStat) {
    TmUnit = GStat.TmUnit;
    StatFSet = GStat.StatFSet;
    GStatV = GStat.GStatV;
  }
  return *this;
}
PGStat TGStatVec::operator[] ( const int &  ValN) const [inline]

Definition at line 185 of file gstat.h.

{ return GStatV[ValN]; }
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 529 of file gstat.cpp.

                                                                                                                                                     {
  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 548 of file gstat.cpp.

                                                                                                                                    {
  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 434 of file gstat.cpp.

                                      {
  TInt(TmUnit).Save(SOut);
  StatFSet.Save(SOut);
  GStatV.Save(SOut);
}
void TGStatVec::SaveTxt ( const TStr FNmPref,
const TStr Desc 
) const

Definition at line 584 of file gstat.cpp.

                                                                   {
  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]

Definition at line 199 of file gstat.h.

{ StatFSet = TakeStatSet; }
void TGStatVec::SetTmUnit ( const TTmUnit TimeUnit) [inline]

Definition at line 197 of file gstat.h.

{ TmUnit = TimeUnit; }
void TGStatVec::Sort ( const TGStatVal SortBy = gsvNodes,
const bool &  Asc = true 
)

Definition at line 483 of file gstat.cpp.

                                                             {
  GStatV.SortCmp(TGStat::TCmpByVal(SortBy, Asc));
}

Friends And Related Function Documentation

friend class TPt< TGStatVec > [friend]

Definition at line 213 of file gstat.h.


Member Data Documentation

Definition at line 159 of file gstat.h.

Definition at line 162 of file gstat.h.

Definition at line 157 of file gstat.h.

Definition at line 161 of file gstat.h.

Definition at line 160 of file gstat.h.


The documentation for this class was generated from the following files: