55 "Usage: rw [options] <graph-file> <out-file>",
57 " Required parameters",
59 " The name of the file storing the transactions. The file is in ",
60 " Metis' graph format.",
62 " Optional parameters",
64 " Specifies the maximum number of iterations. [default: 100]",
67 " Specifies the follow-the-adjacent-links probability. [default: 0.80]",
70 " Specifies the error tollerance. [default: 1e-10]",
73 " Specifies the source of the personalized PR. [default: -1]",
76 " Specifies the number of test-vectors to compute. [default: -1]",
79 " Prints this message.",
85 " Usage: rw [options] <graph-file> <out-file>",
86 " use 'rw -help' for a summary of the options.",
103 int main(
int argc,
char *argv[])
121 if (params->
ntvs != -1) {
125 prs = gk_fAllocMatrix(params->
ntvs, mat->
nrows, 0.0,
"main: prs");
128 for (j=0; j<params->
ntvs; j++) {
129 for (i=0; i<mat->
nrows; i++)
131 gk_fscale(mat->
nrows, 1.0/gk_fsum(mat->
nrows, prs[j], 1), prs[j], 1);
134 printf(
"tvs#: %zd; niters: %zd\n", j, niter);
139 for (i=0; i<mat->
nrows; i++) {
140 for (j=0; j<params->
ntvs; j++)
141 fprintf(fpout,
"%.4e ", prs[j][i]);
142 fprintf(fpout,
"\n");
146 gk_fFreeMatrix(&prs, params->
ntvs, mat->
nrows);
148 else if (params->
ppr != -1) {
152 pr = gk_fsmalloc(mat->
nrows, 0.0,
"main: pr");
154 pr[params->
ppr-1] = 1.0;
157 printf(
"ppr: %d; niters: %zd\n", params->
ppr, niter);
161 for (i=0; i<mat->
nrows; i++)
162 fprintf(fpout,
"%.4e\n", pr[i]);
173 pr = gk_fsmalloc(mat->
nrows, 1.0/mat->
nrows,
"main: pr");
176 printf(
"pr; niters: %zd\n", niter);
180 for (i=0; i<mat->
nrows; i++) {
181 for (jmax=i, maxdiff=0.0, j=mat->
rowptr[i]; j<mat->rowptr[i+1]; j++) {
182 if ((diff =
fabs(pr[i]-pr[mat->
rowind[j]])) > maxdiff) {
187 fprintf(fpout,
"%.4e %10zd %.4e %10d\n", pr[i],
208 printf(
"*******************************************************************************\n");
210 printf(
"Matrix Information ---------------------------------------------------------\n");
211 printf(
" input file=%s, [%d, %d, %zd]\n",
215 printf(
"Options --------------------------------------------------------------------\n");
216 printf(
" niter=%d, ntvs=%d, ppr=%d, lamda=%f, eps=%e\n",
220 printf(
"Performing random walks... ----------------------------------------------\n");
230 printf(
"Memory Usage Information -----------------------------------------------------\n");
233 printf(
"********************************************************************************\n");
253 params->
lamda = 0.80;
278 for (i=0; strlen(
helpstr[i]) > 0; i++)
284 printf(
"Illegal command-line option(s)\nUse %s -help for a summary of the options.\n", argv[0]);
290 printf(
"Unrecognized parameters.");
302 if (params->
ppr != -1 && params->
ntvs != -1)
303 errexit(
"Only one of the -ppr and -ntvs options can be specified.\n");
The structure that stores the information about the command-line options.
FILE * gk_fopen(char *, char *, const char *)
void errexit(char *f_str,...)
int gk_optind
Index in ARGV of the next element to be scanned.
static char helpstr[][100]
void print_final_info(params_t *params)
size_t gk_GetMaxMemoryUsed()
int gk_fexists(char *fname)
void print_init_info(params_t *params, gk_csr_t *mat)
static struct gk_option long_options[]
static const SmartProjectionParams params
static char shorthelpstr[][100]
size_t gk_GetCurMemoryUsed()
Array< double, 1, 3 > e(1./3., 0.5, 2.)
params_t * parse_cmdline(int argc, char *argv[])
char * gk_strdup(char *orgstr)
Duplicates a string.
char * gk_optarg
For communication arguments to the caller.
void gk_csr_Free(gk_csr_t **mat)
void * gk_malloc(size_t nbytes, char *msg)
void gk_free(void **ptr1,...)
int gk_rw_PageRank(gk_csr_t *mat, float lamda, float eps, int max_niter, float *pr)
int main(int argc, char *argv[])
int gk_getopt_long_only(int argc, char **argv, char *options, struct gk_option *long_options, int *opt_index)
Parse command-line arguments with only long options.
gk_csr_t * gk_csr_Read(char *filename, int format, int readvals, int numbering)