diff --git a/ds/network.py b/ds/network.py index be3a40e..c14500a 100644 --- a/ds/network.py +++ b/ds/network.py @@ -265,6 +265,8 @@ def a_random_walk(self, node, length): return walk if len(self.graph[node]) == 0: return walk + if not self.node_choices[node]: + return walk #******************* next_node, edge_class_id =random.choice(self.node_choices[node]) walk.append(edge_class_id) diff --git a/model_c/src/hin2vec.c b/model_c/src/hin2vec.c index e0b2670..69a668c 100644 --- a/model_c/src/hin2vec.c +++ b/model_c/src/hin2vec.c @@ -398,7 +398,7 @@ void DestroyNet() { void *TrainModelThread(void *id) { long long a, b, d, w, cur_win, word, node_length = 0; long long mp_index, edge_length = 0; - char *mp = ""; + char *mp; long long rw_length = 0; char item[MAX_STRING]; char rw[MAX_RW_LENGTH][MAX_STRING], edge_seq[MAX_RW_LENGTH][MAX_STRING]; @@ -421,7 +421,9 @@ void *TrainModelThread(void *id) { exit(1); } fseek(fi, file_size / (long long)num_threads * (long long)id, SEEK_SET); - + + while (fgetc(fi)!=' '&&feof(fi)!=1); // make sure the cursor is not positioned "in" a word + while (1) { if (word_count - last_word_count > 10000) { word_count_actual += word_count - last_word_count; @@ -501,7 +503,8 @@ void *TrainModelThread(void *id) { if (has_circle) continue; } - mp = edge_seq[a]; + char mp[MAX_STRING]={0}; + strcpy(mp,edge_seq[a]); for (b=1; b