SNAP Library 2.2, Developer Reference
2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <mag.h>
Public Member Functions | |
TMAGNodeBeta () | |
TMAGNodeBeta (const int &_Dim, const double &Alpha=1, const double &Beta=1) | |
TMAGNodeBeta (const TFltV &_AlphaV, const TFltV &_BetaV) | |
TMAGNodeBeta & | operator= (const TMAGNodeBeta &Dist) |
void | SetBeta (const int &Attr, const double &Alpha, const double &Beta) |
void | GetBeta (const int &Attr, double &Alpha, double &Beta) const |
void | SetBetaV (const TFltV &_AlphaV, const TFltV &_BetaV) |
void | GetBetaV (TFltV &_AlphaV, TFltV &_BetaV) const |
bool | GetMuV (TFltV &_MuV) const |
void | LoadTxt (const TStr &InFNm) |
void | SaveTxt (TStrV &OutStrV) const |
void | AttrGen (TIntVV &AttrVV, const int &NNodes) |
Static Public Attributes | |
static TRnd | Rnd = TRnd(0) |
Private Attributes | |
TFltV | AlphaV |
TFltV | BetaV |
TFltV | MuV |
TInt | Dim |
TBool | Dirty |
TMAGNodeBeta::TMAGNodeBeta | ( | ) | [inline] |
TMAGNodeBeta::TMAGNodeBeta | ( | const int & | _Dim, |
const double & | Alpha = 1 , |
||
const double & | Beta = 1 |
||
) | [inline] |
TMAGNodeBeta::TMAGNodeBeta | ( | const TFltV & | _AlphaV, |
const TFltV & | _BetaV | ||
) | [inline] |
void TMAGNodeBeta::AttrGen | ( | TIntVV & | AttrVV, |
const int & | NNodes | ||
) |
Definition at line 323 of file mag.cpp.
References AlphaV, TVVec< TVal >::At(), BetaV, Dim, Dirty, TVVec< TVal >::Gen(), TRnd::GetGammaDev(), IAssert, MuV, and TVVec< TVal >::PutAll().
{ IAssert(Dim > 0); AttrVV.Gen(NNodes, Dim); AttrVV.PutAll(0); // printf("AlphaV = %d, BetaV = %d, MuV = %d\n", AlphaV.Len(), BetaV.Len(), MuV.Len()); for(int i = 0; i < NNodes; i++) { for(int l = 0; l < Dim; l++) { double x = TMAGNodeBeta::Rnd.GetGammaDev((int)AlphaV[l]); double y = TMAGNodeBeta::Rnd.GetGammaDev((int)BetaV[l]); MuV[l] = x / (x + y); if((TMAGNodeBeta::Rnd).GetUniDev() > MuV[l]) { AttrVV.At(i, l) = 1; } } } Dirty = false; }
void TMAGNodeBeta::GetBeta | ( | const int & | Attr, |
double & | Alpha, | ||
double & | Beta | ||
) | const [inline] |
void TMAGNodeBeta::GetBetaV | ( | TFltV & | _AlphaV, |
TFltV & | _BetaV | ||
) | const [inline] |
bool TMAGNodeBeta::GetMuV | ( | TFltV & | _MuV | ) | const [inline] |
void TMAGNodeBeta::LoadTxt | ( | const TStr & | InFNm | ) |
Definition at line 343 of file mag.cpp.
References TVec< TVal, TSizeTy >::Add(), AlphaV, BetaV, TStr::CStr(), Dim, TVec< TVal, TSizeTy >::Gen(), TStr::GetFlt(), and IAssertR.
{ FILE *fp = fopen(InFNm.CStr(), "r"); IAssertR(fp != NULL, "File does not exist: " + InFNm); Dim = 0; AlphaV.Gen(10, 0); BetaV.Gen(10, 0); char buf[128]; char *token; TStr TokenStr; TFlt Val; while(fgets(buf, sizeof(buf), fp) != NULL) { token = strtok(buf, "&"); token = strtok(token, " \t"); TokenStr = TStr(token); AlphaV.Add(TokenStr.GetFlt(Val)); token = strtok(NULL, " \t"); TokenStr = TStr(token); BetaV.Add(TokenStr.GetFlt(Val)); Dim++; } fclose(fp); }
TMAGNodeBeta & TMAGNodeBeta::operator= | ( | const TMAGNodeBeta & | Dist | ) |
void TMAGNodeBeta::SaveTxt | ( | TStrV & | OutStrV | ) | const |
Definition at line 373 of file mag.cpp.
References TVec< TVal, TSizeTy >::Add(), AlphaV, BetaV, Dim, TStr::Fmt(), and TVec< TVal, TSizeTy >::Gen().
{ OutStrV.Gen(Dim, 0); for(int i = 0; i < Dim; i++) { OutStrV.Add(TStr::Fmt("%f %f", double(AlphaV[i]), double(BetaV[i]))); } }
void TMAGNodeBeta::SetBeta | ( | const int & | Attr, |
const double & | Alpha, | ||
const double & | Beta | ||
) |
void TMAGNodeBeta::SetBetaV | ( | const TFltV & | _AlphaV, |
const TFltV & | _BetaV | ||
) |
TFltV TMAGNodeBeta::AlphaV [private] |
Definition at line 119 of file mag.h.
Referenced by AttrGen(), GetBeta(), GetBetaV(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().
TFltV TMAGNodeBeta::BetaV [private] |
Definition at line 120 of file mag.h.
Referenced by AttrGen(), GetBeta(), GetBetaV(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().
TInt TMAGNodeBeta::Dim [private] |
Definition at line 122 of file mag.h.
Referenced by AttrGen(), GetBeta(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().
TBool TMAGNodeBeta::Dirty [private] |
Definition at line 123 of file mag.h.
Referenced by AttrGen(), GetMuV(), operator=(), SetBeta(), and SetBetaV().
TFltV TMAGNodeBeta::MuV [private] |
Definition at line 121 of file mag.h.
Referenced by AttrGen(), GetMuV(), operator=(), and TMAGNodeBeta().
TRnd TMAGNodeBeta::Rnd = TRnd(0) [static] |