SNAP Library 2.2, User 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
TMAGNodeBern Class Reference

#include <mag.h>

List of all members.

Public Member Functions

 TMAGNodeBern ()
 TMAGNodeBern (const int &_Dim, const double &_Mu=0.5)
 TMAGNodeBern (const TFltV &_MuV)
 TMAGNodeBern (const TMAGNodeBern &Dist)
TMAGNodeBernoperator= (const TMAGNodeBern &Dist)
void SetMuV (const TFltV &_MuV)
const TFltVGetMuV () const
void SetMu (const int &Attr, const double &Prob)
double GetMu (const int &Attr) 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 MuV
TInt Dim

Detailed Description

Definition at line 88 of file mag.h.


Constructor & Destructor Documentation

Definition at line 95 of file mag.h.

: MuV(), Dim(-1) {}
TMAGNodeBern::TMAGNodeBern ( const int &  _Dim,
const double &  _Mu = 0.5 
) [inline]

Definition at line 96 of file mag.h.

: MuV(_Dim), Dim(_Dim) {  IAssert(_Mu >= 0.0 && _Mu <= 1.0);  MuV.PutAll(_Mu);  }
TMAGNodeBern::TMAGNodeBern ( const TFltV _MuV) [inline]

Definition at line 97 of file mag.h.

: MuV(_MuV), Dim(_MuV.Len()) {}
TMAGNodeBern::TMAGNodeBern ( const TMAGNodeBern Dist) [inline]

Definition at line 98 of file mag.h.

: MuV(Dist.MuV), Dim(Dist.Dim) {}

Member Function Documentation

void TMAGNodeBern::AttrGen ( TIntVV AttrVV,
const int &  NNodes 
)

Definition at line 250 of file mag.cpp.

                                                            {
        IAssert(Dim > 0);
        AttrVV.Gen(NNodes, Dim);
        AttrVV.PutAll(0);
        
        for(int i = 0; i < NNodes; i++) {
                for(int l = 0; l < Dim; l++) {
                        if((TMAGNodeBern::Rnd).GetUniDev() > MuV[l]) {
                                AttrVV.At(i, l) = 1;
                        }
                }
        }
}
double TMAGNodeBern::GetMu ( const int &  Attr) const [inline]

Definition at line 105 of file mag.h.

{  return MuV[Attr];  }
const TFltV& TMAGNodeBern::GetMuV ( ) const [inline]

Definition at line 103 of file mag.h.

{  return MuV;  }
void TMAGNodeBern::LoadTxt ( const TStr InFNm)

Definition at line 264 of file mag.cpp.

                                            {
        FILE *fp = fopen(InFNm.CStr(), "r");
        IAssertR(fp != NULL, "File does not exist: " + InFNm);

        Dim = 0;
        MuV.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);
                MuV.Add(TokenStr.GetFlt(Val));
        }
        Dim = MuV.Len();

        fclose(fp);
}
TMAGNodeBern & TMAGNodeBern::operator= ( const TMAGNodeBern Dist)

Definition at line 244 of file mag.cpp.

                                                              {
        MuV = Dist.MuV;
        Dim = Dist.Dim;
        return (*this);
}
void TMAGNodeBern::SaveTxt ( TStrV OutStrV) const

Definition at line 287 of file mag.cpp.

                                               {
        OutStrV.Gen(Dim, 0);

        for(int i = 0; i < Dim; i++) {
                OutStrV.Add(TStr::Fmt("%f", double(MuV[i])));
        }
}
void TMAGNodeBern::SetMu ( const int &  Attr,
const double &  Prob 
) [inline]

Definition at line 104 of file mag.h.

{  IAssert(Prob >= 0.0 && Prob <= 1.0);  MuV[Attr] = Prob;  }
void TMAGNodeBern::SetMuV ( const TFltV _MuV) [inline]

Definition at line 102 of file mag.h.

{  MuV = _MuV;  }

Member Data Documentation

Definition at line 93 of file mag.h.

Definition at line 92 of file mag.h.

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

Definition at line 90 of file mag.h.


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