20 printf(
"\nHelp\nTo cluster a graph into a given number of clusters:\n %s [options] graph_file number_of_clusters\n", program_name);
21 printf(
" options: -o ncut|rassoc\n");
22 printf(
" \t\t ncut --- normalized cut (default)\n\t\t rassoc --- ratio association\n");
23 printf(
" -l number_of_local_search_steps (default is 0)\n");
24 printf(
" -b use only boundary points (default is to use all points)\n");
26 printf(
"\nTo compute objective function value for a given clustering:\n %s [options] -e clustering_file graph_file\n\n", program_name);
38 for (i=0; i<nvtxs; i++)
39 clustersize[where[i]] ++;
49 idxtype *adjwgt, *adjncy, *xadj;
56 for (i=0; i<nvtxs; i++)
57 for (j=0; j<nvtxs; j++)
61 for (i=0; i<nvtxs; i++)
62 for (j=xadj[i]; j<xadj[i+1]; j++)
63 dense[i* nvtxs+adjncy[j]] = 1;
65 for (i=0; i<nvtxs; i++)
66 for (j=xadj[i]; j<xadj[i+1]; j++)
67 dense[i* nvtxs+adjncy[j]] = m_adjwgt[j];
77 for(i=
length-1; i>=0; i--)
78 if ((
path[i] ==
'/') || (
path[i] ==
'\\'))
101 char out1[256], out2[256];
103 va_start(argp, f_str);
104 vsprintf(out1, f_str, argp);
107 sprintf(out2,
"Error! %s", out1);
109 fprintf(stdout, out2);
136 if ((n == 0) || (m==0))
139 temp = (
float **)
GKmalloc(
sizeof(
float *)*n, msg);
141 temp[i] = (
float *)
GKmalloc(
sizeof(
float)*m, msg);
152 if ((n == 0) || (m==0))
155 temp = (
int **)
GKmalloc(
sizeof(
int *)*n, msg);
157 temp[i] = (
int *)
GKmalloc(
sizeof(
int)*m, msg);
169 return (
int *)
GKmalloc(
sizeof(
int)*n, msg);
193 return (
float *)
GKmalloc(
sizeof(
float)*n, msg);
205 return iset(n, ival, (
int *)
GKmalloc(
sizeof(
int)*n, msg));
232 ptr = (
void *)malloc(nbytes);
234 graclus_errexit(
"***Memory allocation failed for %s. Requested size: %d bytes", msg, nbytes);
252 va_start(plist, ptr1);
255 while ((ptr = va_arg(plist,
void **)) !=
LTERM) {
268 int *
iset(
int n,
int val,
int *x)
296 float *
sset(
int n,
float val,
float *x)
343 for (i=incx; i<n; i+=incx)
380 for (i=2; i<n; i++) {
381 if (x[i] > x[max1]) {
385 else if (x[i] > x[max2])
442 for (i=0; i<n; i++, x+=incx) {
508 for (i=0; i<n; i++, x+=incx)
517 void sscale(
int n,
float alpha,
float *x)
534 for (i = 0; i<n; i++)
545 float sdot(
int n,
float *x,
float *y)
550 for (i = 0; i<n; i++)
560 void saxpy(
int n,
float alpha,
float *x,
int incx,
float *y,
int incy)
564 for (i=0; i<n; i++, x+=incx, y+=incy)
586 for(i = 1; i < n; i++)
625 chunksize = n / k +1;
629 if ((i+1)% chunksize ==0)
642 for (; a%2 != 1; a = a>>1);
643 return (a > 1 ? 0 : 1);
667 for (i=1; a > 1; i++, a = a>>1);
__host__ __device__ float length(float2 v)
static const std::string path
int idxamax(int n, idxtype *x)
Chains * chainmalloc(int n, char *msg)
void sparse2dense(GraphType *graph, double *dense, float *m_adjwgt)
void graclus_errexit(char *f_str,...)
void RandomPermute(int n, idxtype *p, int flag)
int idxamin(int n, idxtype *x)
int * ismalloc(int n, int ival, char *msg)
void sscale(int n, float alpha, float *x)
void idxadd(int n, idxtype *x, idxtype *y)
int samax(int n, float *x)
float sdot(int n, float *x, float *y)
idxtype * idxmalloc(int n, char *msg)
int idxsum_strd(int n, idxtype *x, int incx)
int idxamax_strd(int n, idxtype *x, int incx)
int ** i2malloc(int n, int m, char *msg)
int idxsum(int n, idxtype *x)
int * iset(int n, int val, int *x)
void GKfree(void **ptr1,...)
idxtype * idxset(int n, idxtype val, idxtype *x)
int charsum(int n, char *x)
void extractfilename(char *path, char *name)
void RandomInit(int n, int k, idxtype *label)
int samax2(int n, float *x)
void print_help(char *program_name)
float * sset(int n, float val, float *x)
int samin(int n, float *x)
void * GKmalloc(int nbytes, char *msg)
float ssum_strd(int n, float *x, int incx)
void InitRandom(int seed)
idxtype * idxsmalloc(int n, idxtype ival, char *msg)
float * fmalloc(int n, char *msg)
float snorm2(int n, float *v)
void clusterSize(GraphType *graph, int *clustersize)
float ** f2malloc(int n, int m, char *msg)
float ssum(int n, float *x)
int * imalloc(int n, char *msg)
void saxpy(int n, float alpha, float *x, int incx, float *y, int incy)