-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconductance.c
59 lines (50 loc) · 1.01 KB
/
conductance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include "defs.h"
#include "globals.h"
#include <malloc.h>
#if !defined(__MTA__)
#include "compat/xmt-ops.h"
#endif
#include "stinger-atomics.h"
/* Input array *membership indicates the "cut" using 0 and 1
for each vertex in the graph. */
double computeConductanceValue(graph * G, int64_t *membership)
{
int64_t i,j;
int64_t comm;
double cond = 0.0;
int64_t interST = 0;
int64_t intraS = 0;
int64_t intraT = 0;
OMP("omp parallel for")
MTA("mta assert parallel")
for(i=0; i<G->numVertices; i++)
{
comm = membership[i];
for(j=G->edgeStart[i]; j<G->edgeStart[i+1]; j++)
{
if(membership[G->endVertex[j]] == comm)
{
stinger_int_fetch_add(&interST, 1);
}
else if(comm == 1)
{
stinger_int_fetch_add(&intraS, 1);
}
else
{
stinger_int_fetch_add(&intraT, 1);
}
}
}
if(intraS > intraT)
{
cond = interST/(double) (interST + intraT);
}
else
{
cond = interST/(double) (interST + intraS);
}
printf("Conductance is: %9.6lf\n", cond );
return cond;
}