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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TMAGNodeBeta Class Reference

#include <mag.h>

Collaboration diagram for TMAGNodeBeta:

List of all members.

Public Member Functions

 TMAGNodeBeta ()
 TMAGNodeBeta (const int &_Dim, const double &Alpha=1, const double &Beta=1)
 TMAGNodeBeta (const TFltV &_AlphaV, const TFltV &_BetaV)
TMAGNodeBetaoperator= (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

Detailed Description

Definition at line 115 of file mag.h.


Constructor & Destructor Documentation

Definition at line 125 of file mag.h.

: AlphaV(), BetaV(), MuV(), Dim(-1), Dirty(true) {}
TMAGNodeBeta::TMAGNodeBeta ( const int &  _Dim,
const double &  Alpha = 1,
const double &  Beta = 1 
) [inline]

Definition at line 126 of file mag.h.

References AlphaV, BetaV, and TVec< TVal, TSizeTy >::PutAll().

: AlphaV(_Dim), BetaV(_Dim), MuV(_Dim), Dim(_Dim), Dirty(true) {  AlphaV.PutAll(Alpha);  BetaV.PutAll(Beta);  }

Here is the call graph for this function:

TMAGNodeBeta::TMAGNodeBeta ( const TFltV _AlphaV,
const TFltV _BetaV 
) [inline]

Definition at line 127 of file mag.h.

References Dim, TVec< TVal, TSizeTy >::Gen(), IAssert, TVec< TVal, TSizeTy >::Len(), and MuV.

: AlphaV(_AlphaV), BetaV(_BetaV), Dirty(true) {  IAssert(_AlphaV.Len() == _BetaV.Len());  Dim = _AlphaV.Len();  MuV.Gen(Dim);  }

Here is the call graph for this function:


Member Function Documentation

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

Here is the call graph for this function:

void TMAGNodeBeta::GetBeta ( const int &  Attr,
double &  Alpha,
double &  Beta 
) const [inline]

Definition at line 132 of file mag.h.

References AlphaV, BetaV, Dim, and IAssert.

{  IAssert(Attr < Dim);  Alpha = AlphaV[Attr];  Beta = BetaV[Attr];  }
void TMAGNodeBeta::GetBetaV ( TFltV _AlphaV,
TFltV _BetaV 
) const [inline]

Definition at line 134 of file mag.h.

References AlphaV, and BetaV.

{  _AlphaV = AlphaV;  _BetaV = BetaV;  }
bool TMAGNodeBeta::GetMuV ( TFltV _MuV) const [inline]

Definition at line 135 of file mag.h.

References Dirty, and MuV.

{  if(!Dirty)  {  _MuV = MuV;  }  return Dirty; }
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);
}

Here is the call graph for this function:

TMAGNodeBeta & TMAGNodeBeta::operator= ( const TMAGNodeBeta Dist)

Definition at line 299 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, and MuV.

                                                              {
        AlphaV = Dist.AlphaV;
        BetaV = Dist.BetaV;
        Dim = Dist.Dim;
        MuV = Dist.MuV;
        Dirty = Dist.Dirty;
        return (*this);
}
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])));
        }
}

Here is the call graph for this function:

void TMAGNodeBeta::SetBeta ( const int &  Attr,
const double &  Alpha,
const double &  Beta 
)

Definition at line 308 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, and IAssert.

                                                                                   {
        IAssert(Attr < Dim);
        AlphaV[Attr] = Alpha;
        BetaV[Attr] = Beta;
        Dirty = true;
}
void TMAGNodeBeta::SetBetaV ( const TFltV _AlphaV,
const TFltV _BetaV 
)

Definition at line 315 of file mag.cpp.

References AlphaV, BetaV, Dim, Dirty, IAssert, and TVec< TVal, TSizeTy >::Len().

                                                                     {
        IAssert(_AlphaV.Len() == _BetaV.Len());
        AlphaV = _AlphaV;
        BetaV = _BetaV;
        Dim = _AlphaV.Len();
        Dirty = true;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 122 of file mag.h.

Referenced by AttrGen(), GetBeta(), LoadTxt(), operator=(), SaveTxt(), SetBeta(), SetBetaV(), and TMAGNodeBeta().

Definition at line 123 of file mag.h.

Referenced by AttrGen(), GetMuV(), operator=(), SetBeta(), and SetBetaV().

Definition at line 121 of file mag.h.

Referenced by AttrGen(), GetMuV(), operator=(), and TMAGNodeBeta().

TRnd TMAGNodeBeta::Rnd = TRnd(0) [static]

Definition at line 117 of file mag.h.


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