~vtraag/louvain/release-0.1

« back to all changes in this revision

Viewing changes to src/Base/greedy_louvain.h

  • Committer: Vincent Traag
  • Date: 2011-05-26 17:28:12 UTC
  • Revision ID: vtraag@f-m.fm-20110526172812-qtsq5n47ptwtmxs2
Fixed some minor issues, removed dependence on pthread library, changed the consideration of communities for negative links.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#ifndef GREEDY_LOUVAIN_H
42
42
#define GREEDY_LOUVAIN_H
43
43
 
 
44
//#define THREAD_SUPPORT
 
45
 
44
46
#define NODES_PER_THREAD 10000
45
47
 
46
48
#include "community.h"
48
50
#include <queue>
49
51
#include <algorithm>
50
52
 
 
53
#ifdef THREAD_SUPPORT
51
54
#include <pthread.h>
52
55
#include <errno.h>
 
56
#endif
53
57
 
54
58
#include "../MTRand/MersenneTwister.h"
55
59
 
105
109
    // Keep track of the increase in modularity
106
110
    double diff;
107
111
 
 
112
#ifdef THREAD_SUPPORT
108
113
    // Keep track of the number of threads that have finished their part of the pass
109
114
    int nb_threads_finished_pass;
110
115
 
160
165
    int* thread_id_per_node;
161
166
    set<int>unclaimed_nodes;
162
167
 
 
168
#endif
 
169
 
163
170
    // Functions
164
171
    void reset_sync();
165
172
    ThreadSync(int nb_nodes, int nb_threads);   // Constructor
169
176
  // compute communities of the graph for one level
170
177
  // returns the modularity
171
178
  static double one_level(Community* c);
 
179
#ifdef THREAD_SUPPORT  
172
180
  static void* one_level_thread(void* cc); //Do threaded community detection (one level)
 
181
#endif  
173
182
  static double one_level_single(Community* cc, ThreadSync* ts); // Run a single level (without multiple threads)
174
183
 
175
184
  static void random_shuffle(deque<int> &v, MTRand* r);
177
186
  // Use this PRNG to initialize the seed (to avoid multhread problems when detecting communities
178
187
  // repeatedly, i.e. when probing resolution parameters)
179
188
  //static MTRand& mt_rand();
 
189
#ifdef THREAD_SUPPORT  
180
190
  static pthread_mutex_t rand_lock;
181
191
 
182
192
  struct level_thread_data
185
195
    ThreadSync* ts;
186
196
    int thread_id;
187
197
  };
 
198
#endif
 
199
  
188
200
};
189
201
#endif