SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TMAGNodeSimple Class Reference

#include <mag.h>

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.

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.

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:2268
static TRnd Rnd
Definition: mag.h:69
TInt Dim
Definition: mag.h:72
void Gen(const TSizeTy &_XDim, const TSizeTy &_YDim)
Definition: ds.h:2247
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2256
void TMAGNodeSimple::LoadTxt ( const TStr InFNm)

Definition at line 215 of file mag.cpp.

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:1386
double GetFlt() const
Definition: dt.h:631
Definition: dt.h:412
char * CStr()
Definition: dt.h:479
TMAGNodeSimple& TMAGNodeSimple::operator= ( const TMAGNodeSimple Simple)
inline

Definition at line 78 of file mag.h.

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.

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

Member Data Documentation

TInt TMAGNodeSimple::Dim
private

Definition at line 72 of file mag.h.

TFlt TMAGNodeSimple::Mu
private

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: