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
TMAGNodeSimple Class Reference

#include <mag.h>

List of all members.

Public Member Functions

 TMAGNodeSimple ()
 TMAGNodeSimple (const int &_Dim, const double &_Mu=0.5)
 TMAGNodeSimple (const TMAGNodeSimple &Simple)
TMAGNodeSimpleoperator= (const TMAGNodeSimple &Simple)
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

TFlt Mu
TInt Dim

Detailed Description

Definition at line 67 of file mag.h.


Constructor & Destructor Documentation

Definition at line 74 of file mag.h.

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

Definition at line 75 of file mag.h.

: Dim(_Dim) {  IAssert(_Mu >= 0.0 && _Mu <= 1.0);  Mu = _Mu;  }
TMAGNodeSimple::TMAGNodeSimple ( const TMAGNodeSimple Simple) [inline]

Definition at line 76 of file mag.h.

: Mu(Simple.Mu), Dim(Simple.Dim) {}

Member Function Documentation

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

Definition at line 201 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((TMAGNodeSimple::Rnd).GetUniDev() > Mu) {
                                AttrVV.At(i, l) = 1;
                        }
                }
        }
}
void TMAGNodeSimple::LoadTxt ( const TStr InFNm)

Definition at line 215 of file mag.cpp.

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

        char buf[128];
        char *token;
        TStr TokenStr;
        TFlt Val;

        token = strtok(buf, "&");
        token = strtok(token, " \t");
        TokenStr = TStr(token);
        Mu = TokenStr.GetFlt(Val);

        fclose(fp);
}
TMAGNodeSimple& TMAGNodeSimple::operator= ( const TMAGNodeSimple Simple) [inline]

Definition at line 78 of file mag.h.

{  Mu = Simple.Mu;  Dim = Simple.Dim;  return (*this);  }
void TMAGNodeSimple::SaveTxt ( TStrV OutStrV) const

Definition at line 232 of file mag.cpp.

                                                 {
        OutStrV.Gen(Dim, 0);

        for(int i = 0; i < Dim; i++) {
                OutStrV.Add(TStr::Fmt("%f", double(Mu)));
        }
}

Member Data Documentation

Definition at line 72 of file mag.h.

Definition at line 71 of file mag.h.

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

Definition at line 69 of file mag.h.


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