SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMAGNodeSimple Class Reference

#include <mag.h>

Collaboration diagram for TMAGNodeSimple:

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

TMAGNodeSimple::TMAGNodeSimple ( )
inline

Definition at line 74 of file mag.h.

74 : Mu(0.5), Dim(-1) {}
TFlt Mu
Definition: mag.h:71
TInt Dim
Definition: mag.h:72
TMAGNodeSimple::TMAGNodeSimple ( const int &  _Dim,
const double &  _Mu = 0.5 
)
inline

Definition at line 75 of file mag.h.

References IAssert, and Mu.

75 : Dim(_Dim) { IAssert(_Mu >= 0.0 && _Mu <= 1.0); Mu = _Mu; }
#define IAssert(Cond)
Definition: bd.h:262
TFlt Mu
Definition: mag.h:71
TInt Dim
Definition: mag.h:72
TMAGNodeSimple::TMAGNodeSimple ( const TMAGNodeSimple Simple)
inline

Definition at line 76 of file mag.h.

76 : Mu(Simple.Mu), Dim(Simple.Dim) {}
TFlt Mu
Definition: mag.h:71
TInt Dim
Definition: mag.h:72

Member Function Documentation

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

Definition at line 201 of file mag.cpp.

References TVVec< TVal, TSizeTy >::At(), Dim, TVVec< TVal, TSizeTy >::Gen(), IAssert, Mu, and TVVec< TVal, TSizeTy >::PutAll().

201  {
202  IAssert(Dim > 0);
203  AttrVV.Gen(NNodes, Dim);
204  AttrVV.PutAll(0);
205 
206  for(int i = 0; i < NNodes; i++) {
207  for(int l = 0; l < Dim; l++) {
208  if((TMAGNodeSimple::Rnd).GetUniDev() > Mu) {
209  AttrVV.At(i, l) = 1;
210  }
211  }
212  }
213 }
#define IAssert(Cond)
Definition: bd.h:262
TFlt Mu
Definition: mag.h:71
void PutAll(const TVal &Val)
Definition: ds.h:2267
static TRnd Rnd
Definition: mag.h:69
TInt Dim
Definition: mag.h:72
void Gen(const TSizeTy &_XDim, const TSizeTy &_YDim)
Definition: ds.h:2246
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2255

Here is the call graph for this function:

void TMAGNodeSimple::LoadTxt ( const TStr InFNm)

Definition at line 215 of file mag.cpp.

References TStr::CStr(), TStr::GetFlt(), IAssertR, and Mu.

215  {
216  FILE *fp = fopen(InFNm.CStr(), "r");
217  IAssertR(fp != NULL, "File does not exist: " + InFNm);
218 
219  char buf[128];
220  char *token;
221  TStr TokenStr;
222  TFlt Val;
223 
224  token = strtok(buf, "&");
225  token = strtok(token, " \t");
226  TokenStr = TStr(token);
227  Mu = TokenStr.GetFlt(Val);
228 
229  fclose(fp);
230 }
TFlt Mu
Definition: mag.h:71
#define IAssertR(Cond, Reason)
Definition: bd.h:265
Definition: dt.h:1383
double GetFlt() const
Definition: dt.h:628
Definition: dt.h:412
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

TMAGNodeSimple& TMAGNodeSimple::operator= ( const TMAGNodeSimple Simple)
inline

Definition at line 78 of file mag.h.

References Dim, and Mu.

78 { Mu = Simple.Mu; Dim = Simple.Dim; return (*this); }
TFlt Mu
Definition: mag.h:71
TInt Dim
Definition: mag.h:72
void TMAGNodeSimple::SaveTxt ( TStrV OutStrV) const

Definition at line 232 of file mag.cpp.

References TVec< TVal, TSizeTy >::Add(), Dim, TStr::Fmt(), TVec< TVal, TSizeTy >::Gen(), and Mu.

232  {
233  OutStrV.Gen(Dim, 0);
234 
235  for(int i = 0; i < Dim; i++) {
236  OutStrV.Add(TStr::Fmt("%f", double(Mu)));
237  }
238 }
TFlt Mu
Definition: mag.h:71
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt Dim
Definition: mag.h:72
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

Member Data Documentation

TInt TMAGNodeSimple::Dim
private

Definition at line 72 of file mag.h.

Referenced by AttrGen(), operator=(), and SaveTxt().

TFlt TMAGNodeSimple::Mu
private

Definition at line 71 of file mag.h.

Referenced by AttrGen(), LoadTxt(), operator=(), SaveTxt(), and TMAGNodeSimple().

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: