10 for (
int64 i = 0; i < N; i++) {
16 for (
int64 i = 0; i < N; i++) {
24 while (UnderV.
Len() > 0 && OverV.
Len() > 0) {
30 UTbl[Large] = UTbl[Large] + UTbl[Small] - 1;
31 if (UTbl[Large] < 1) {
37 while(UnderV.
Len() > 0){
42 while(OverV.
Len() > 0){
60 if (Verbose && NCnt%100 == 0) {
61 printf(
"\rPreprocessing progress: %.2lf%% ",(
double)NCnt*100/(
double)(InNet->GetNodes()));fflush(stdout);
75 if (!(InNet->GetEDat(CurrI.
GetId(), FId, Weight))){
continue; }
76 if (FId==NI.
GetId()) {
77 PTable.
Add(Weight / ParamP);
78 Psum += Weight / ParamP;
79 }
else if (NbrH.
IsKey(FId)) {
83 PTable.
Add(Weight / ParamQ);
84 Psum += Weight / ParamQ;
98 for (
TWNet::TNodeI NI = InNet->BegNI(); NI < InNet->EndNI(); NI++) {
101 for (
TWNet::TNodeI NI = InNet->BegNI(); NI < InNet->EndNI(); NI++) {
102 for (
int64 i = 0; i < NI.GetOutDeg(); i++) {
109 for (
TWNet::TNodeI NI = InNet->BegNI(); NI < InNet->EndNI(); NI++) {
110 NIds.
Add(NI.GetId());
112 #pragma omp parallel for schedule(dynamic)
113 for (
int64 i = 0; i < NIds.
Len(); i++) {
114 PreprocessNode(InNet, ParamP, ParamQ, InNet->GetNI(NIds[i]), NCnt, Verbose);
116 if(Verbose){ printf(
"\n"); }
121 for (
TWNet::TNodeI NI = InNet->BegNI(); NI < InNet->EndNI(); NI++) {
122 for (
int64 i = 0; i < NI.GetOutDeg(); i++) {
133 if (WalkLen == 1) {
return; }
134 if (InNet->GetNI(StartNId).GetOutDeg() == 0) {
return; }
135 WalkV.
Add(InNet->GetNI(StartNId).GetNbrNId(Rnd.
GetUniDevInt(InNet->GetNI(StartNId).GetOutDeg())));
136 while (WalkV.
Len() < WalkLen) {
139 if (InNet->GetNI(Dst).GetOutDeg() == 0) {
return; }
141 WalkV.
Add(InNet->GetNI(Dst).GetNbrNId(Next));
THash< TInt, TIntVFltVPr > TIntIntVFltVPrH
int64 AliasDrawInt(TIntVFltVPr &NTTable, TRnd &Rnd)
const TVal1 & GetVal1() const
TSizeTy Len() const
Returns the number of elements in the vector.
const TVal2 & GetVal2() const
int64 PredictMemoryRequirements(PWNet &InNet)
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
void GetNodeAlias(TFltV &PTblV, TIntVFltVPr &NTTable)
int GetOutDeg() const
Returns out-degree of the current node.
const TVal & LastLast() const
Returns a reference to the one before last element of the vector.
const TVal & Last() const
Returns a reference to the last element of the vector.
Node iterator. Only forward iteration (operator++) is supported.
void SimulateWalk(PWNet &InNet, int64 StartNId, const int &WalkLen, TRnd &Rnd, TIntV &WalkV)
Simulates one walk and writes it into Walk vector.
int AddKey(const TKey &Key)
void PreprocessNode(PWNet &InNet, const double &ParamP, const double &ParamQ, TWNet::TNodeI NI, int64 &NCnt, const bool &Verbose)
void PreprocessTransitionProbs(PWNet &InNet, const double &ParamP, const double &ParamQ, const bool &Verbose)
Preprocesses transition probabilities for random walks. Has to be called once before SimulateWalk cal...
int GetUniDevInt(const int &Range=0)
bool IsKey(const TKey &Key) const
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void DelLast()
Removes the last element of the vector.
int GetId() const
Returns ID of the current node.
const TNodeData & GetDat() const