SNAP Library , Developer Reference  2013-01-07 14:03:36
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

#include <gstat.h>

Collaboration diagram for TGStatVec:

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 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
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 Statistisc Sequence

Definition at line 147 of file gstat.h.


Constructor & Destructor Documentation

TGStatVec::TGStatVec ( const TTmUnit _TmUnit = tmu1Sec)

Definition at line 354 of file gstat.cpp.

References TGStat::AllStat(), and StatFSet.

Referenced by Load(), and New().

                                           : TmUnit(_TmUnit), StatFSet(), GStatV() {
  StatFSet = TGStat::AllStat();
}

Here is the call graph for this function:

Here is the caller graph for this function:

TGStatVec::TGStatVec ( const TTmUnit _TmUnit,
const TFSet TakeGrowthStat 
)

Definition at line 358 of file gstat.cpp.

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

Definition at line 362 of file gstat.cpp.

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

Definition at line 366 of file gstat.cpp.

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

Member Function Documentation

Definition at line 392 of file gstat.cpp.

References TVec< TVal >::Add(), GStatV, TVec< TVal >::Last(), and TGStat::New().

Referenced by Add(), and TMAGFitBern::PlotProperties().

                      {
  GStatV.Add(TGStat::New());
  return GStatV.Last();
}

Here is the call graph for this function:

Here is the caller graph for this function:

PGStat TGStatVec::Add ( const TSecTm Time,
TStr  GraphNm = TStr() 
)

Definition at line 397 of file gstat.cpp.

References TVec< TVal >::Add(), GStatV, TVec< TVal >::Last(), and TGStat::New().

                                                      {
  GStatV.Add(TGStat::New(Time, GraphNm));
  return GStatV.Last();
}

Here is the call graph for this function:

void TGStatVec::Add ( const PGStat Growth) [inline]

Definition at line 168 of file gstat.h.

References TVec< TVal >::Add(), and GStatV.

{ GStatV.Add(Growth); }

Here is the call graph for this function:

void TGStatVec::Add ( const PNGraph Graph,
const TSecTm Time,
const TStr GraphNm = TStr() 
)

Definition at line 402 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));
}

Here is the call graph for this function:

void TGStatVec::Add ( const PNEGraph Graph,
const TSecTm Time,
const TStr GraphNm = TStr() 
)

Definition at line 410 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));
}

Here is the call graph for this function:

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]; }

Here is the caller graph for this function:

void TGStatVec::Clr ( ) [inline]

Definition at line 171 of file gstat.h.

References TVec< TVal >::Clr(), and GStatV.

{ GStatV.Clr(); }

Here is the call graph for this function:

void TGStatVec::Del ( const int &  ValN) [inline]

Definition at line 181 of file gstat.h.

References TVec< TVal >::Del(), and GStatV.

{ GStatV.Del(ValN); }

Here is the call graph for this function:

void TGStatVec::DelAfter ( const TSecTm Tm)

Definition at line 430 of file gstat.cpp.

References TVec< TVal >::Add(), At(), GStatV, Len(), and TVec< TVal >::Swap().

                                         {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->Time <= Tm) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

Here is the call graph for this function:

void TGStatVec::DelBefore ( const TSecTm Tm)

Definition at line 422 of file gstat.cpp.

References TVec< TVal >::Add(), At(), GStatV, Len(), and TVec< TVal >::Swap().

                                          {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->Time >= Tm) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

Here is the call graph for this function:

void TGStatVec::DelLast ( ) [inline]

Definition at line 182 of file gstat.h.

References TVec< TVal >::DelLast(), and GStatV.

{ GStatV.DelLast(); }

Here is the call graph for this function:

void TGStatVec::DelSmallNodes ( const int &  MinNodes)

Definition at line 438 of file gstat.cpp.

References TVec< TVal >::Add(), At(), GStatV, Len(), and TVec< TVal >::Swap().

                                                 {
  TGStatV NewTickV;
  for (int i = 0; i < Len(); i++) {
    if (At(i)->GetNodes() >= MinNodes) { NewTickV.Add(At(i)); }
  }
  GStatV.Swap(NewTickV);
}

Here is the call graph for this function:

bool TGStatVec::Empty ( ) const [inline]

Definition at line 175 of file gstat.h.

References TVec< TVal >::Empty(), and GStatV.

{ return GStatV.Empty(); }

Here is the call graph for this function:

PGStat TGStatVec::GetAvgGStat ( const bool &  ClipAt1 = false)

Definition at line 456 of file gstat.cpp.

References GStatV, and New().

                                                 {
  PGStat Stat = TGStat::New();
  Stat->AvgGStat(GStatV, ClipAt1);
  return Stat;
}

Here is the call graph for this function:

const TGStatV& TGStatVec::GetGStatV ( ) const [inline]

Definition at line 179 of file gstat.h.

References GStatV.

{ return GStatV; }
TTmUnit TGStatVec::GetTmUnit ( ) const [inline]

Definition at line 188 of file gstat.h.

References TmUnit.

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

Definition at line 446 of file gstat.cpp.

References TVec< TVal >::Add(), At(), TVec< TVal >::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)));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TGStatVec::HasDistr ( const TGStatDistr Stat) const [inline]

Definition at line 191 of file gstat.h.

References TFSet::In(), and StatFSet.

Referenced by ImposeDistr().

{ return StatFSet.In(Stat); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool TGStatVec::HasVal ( const TGStatVal Stat) const [inline]

Definition at line 190 of file gstat.h.

References TFSet::In(), and StatFSet.

Referenced by Plot().

{ return StatFSet.In(Stat); }

Here is the call graph for this function:

Here is the caller graph for this function:

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 492 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();
}

Here is the call graph for this function:

PGStat TGStatVec::Last ( ) const [inline]

Definition at line 178 of file gstat.h.

References GStatV, and TVec< TVal >::Last().

Referenced by ImposeDistr(), Plot(), and PlotAllVsX().

{ return GStatV.Last(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TGStatVec::Len ( ) const [inline]

Definition at line 174 of file gstat.h.

References GStatV, and TVec< TVal >::Len().

Referenced by DelAfter(), DelBefore(), DelSmallNodes(), GetValV(), ImposeDistr(), TMAGFitBern::PlotProperties(), and SaveTxt().

{ return GStatV.Len(); }

Here is the call graph for this function:

Here is the caller graph for this function:

static PGStatVec TGStatVec::Load ( TSIn SIn) [inline, static]

Definition at line 161 of file gstat.h.

References TGStatVec().

{ return new TGStatVec(SIn); }

Here is the call graph for this function:

PGStatVec TGStatVec::New ( const TTmUnit _TmUnit = tmu1Sec) [static]

Definition at line 369 of file gstat.cpp.

References TGStatVec().

Referenced by TFfGGen::GenFFGraphs(), and GetAvgGStat().

                                               {
  return new TGStatVec(_TmUnit);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PGStatVec TGStatVec::New ( const TTmUnit _TmUnit,
const TFSet TakeGrowthStat 
) [static]

Definition at line 373 of file gstat.cpp.

References TGStatVec().

                                                                            {
  return new TGStatVec(_TmUnit, TakeGrowthStat);
}

Here is the call graph for this function:

TGStatVec & TGStatVec::operator= ( const TGStatVec GStat)

Definition at line 383 of file gstat.cpp.

References GStatV, StatFSet, and TmUnit.

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

References GStatV.

{ 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 462 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();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TGStatVec::PlotAllVsX ( const TGStatVal XVal,
const TStr OutFNm,
TStr  Desc = TStr(),
const TGpScaleTy Scale = gpsAuto,
const bool &  PowerFit = false 
) const

Definition at line 481 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);
    }
  }
}

Here is the call graph for this function:

void TGStatVec::Save ( TSOut SOut) const

Definition at line 377 of file gstat.cpp.

References GStatV, TFSet::Save(), TVec< TVal >::Save(), TInt::Save(), StatFSet, and TmUnit.

                                      {
  TInt(TmUnit).Save(SOut);
  StatFSet.Save(SOut);
  GStatV.Save(SOut);
}

Here is the call graph for this function:

void TGStatVec::SaveTxt ( const TStr FNmPref,
const TStr Desc 
) const

Definition at line 517 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 >::Len(), TVec< TVal >::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);
}

Here is the call graph for this function:

void TGStatVec::SetTakeStat ( const TFSet TakeStatSet) [inline]

Definition at line 189 of file gstat.h.

References StatFSet.

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

Definition at line 187 of file gstat.h.

References TmUnit.

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

Definition at line 418 of file gstat.cpp.

References GStatV, and TVec< TVal >::SortCmp().

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

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TGStatVec > [friend]

Definition at line 203 of file gstat.h.


Member Data Documentation

Definition at line 151 of file gstat.h.

Definition at line 149 of file gstat.h.

Referenced by Add().

Definition at line 153 of file gstat.h.

Referenced by Add(), HasDistr(), HasVal(), operator=(), Save(), SetTakeStat(), and TGStatVec().

Definition at line 152 of file gstat.h.

Referenced by GetTmUnit(), operator=(), Save(), SaveTxt(), and SetTmUnit().


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