53 "Usage: gkgraph [options] <graph-file> [<out-file>]",
55 " Required parameters",
57 " The name of the file storing the graph. The file is in ",
58 " Metis' graph format.",
60 " Optional parameters",
62 " Specifies the maximum number of iterations. [default: 100]",
65 " Specifies the follow-the-adjacent-links probability. [default: 0.80]",
68 " Specifies the error tollerance. [default: 1e-10]",
71 " Prints this message.",
77 " Usage: gkgraph [options] <graph-file> [<out-file>]",
78 " use 'gkgraph -help' for a summary of the options.",
97 int main(
int argc,
char *argv[])
119 for (i=0; i<1; i++) {
122 printf(
"BFS from %8d. Compactness: %le\n",
130 printf(
"BestF from %8d. Compactness: %le\n",
138 for (j=0; j<params->
niter; j++) {
140 printf(
"\tAfter centroid; Compactness: %le\n",
168 double compactness=0.0;
171 nvtxs = graph->
nvtxs;
175 freq = gk_ismalloc(nvtxs, 0,
"compute_compactness: freq");
177 for (i=0; i<nvtxs; i++) {
178 v = (perm ==
NULL ?
i : perm[
i]);
179 for (j=xadj[i]; j<xadj[i+1]; j++) {
180 u = (perm ==
NULL ? adjncy[
j] : perm[adjncy[
j]]);
181 compactness +=
fabs(v-u);
192 printf(
"\tnsmall: %d\n", freq[1]+freq[2]+freq[3]);
194 return compactness/xadj[nvtxs];
209 nvtxs = graph->
nvtxs;
213 cand = gk_fkvmalloc(nvtxs,
"reorder_centroid: cand");
215 for (i=0; i<nvtxs; i++) {
219 for (j=xadj[i]; j<xadj[i+1]; j++) {
226 cand[
i].key = v + displacement*params->
lamda/(xadj[i+1]-xadj[
i]);
234 gk_i32set(nvtxs, -1, perm);
235 for (i=0; i<nvtxs; i++) {
236 if (perm[cand[i].
val] != -1)
237 errexit(
"Resetting perm[%d] = %d\n", cand[i].
val, perm[cand[i].val]);
238 perm[cand[
i].val] =
i;
256 printf(
"*******************************************************************************\n");
257 printf(
" gkgraph\n\n");
258 printf(
"Graph Information ----------------------------------------------------------\n");
259 printf(
" input file=%s, [%d, %zd]\n",
263 printf(
"Options --------------------------------------------------------------------\n");
264 printf(
" type=%d, niter=%d, lamda=%f, eps=%e\n",
268 printf(
"Working... -----------------------------------------------------------------\n");
278 printf(
"Memory Usage Information -----------------------------------------------------\n");
281 printf(
"********************************************************************************\n");
300 params->
lamda = 0.20;
321 for (i=0; strlen(
helpstr[i]) > 0; i++)
327 printf(
"Illegal command-line option(s)\nUse %s -help for a summary of the options.\n", argv[0]);
333 printf(
"Unrecognized parameters.");
The structure that stores the information about the command-line options.
gk_graph_t * gk_graph_Read(char *filename, int format, int isfewgts, int isfvwgts, int isfvsizes)
void gk_fkvsorti(size_t, gk_fkv_t *)
void print_init_info(params_t *params, gk_graph_t *graph)
void errexit(char *f_str,...)
double compute_compactness(params_t *params, gk_graph_t *graph, int32_t *perm)
int gk_optind
Index in ARGV of the next element to be scanned.
gk_graph_t * gk_graph_Reorder(gk_graph_t *graph, int32_t *perm, int32_t *iperm)
int main(int argc, char *argv[])
void gk_graph_Write(gk_graph_t *graph, char *filename, int format)
size_t gk_GetMaxMemoryUsed()
int gk_fexists(char *fname)
void gk_graph_Free(gk_graph_t **graph)
static char shorthelpstr[][100]
void print_final_info(params_t *params)
NonlinearFactorGraph graph
static const SmartProjectionParams params
params_t * parse_cmdline(int argc, char *argv[])
size_t gk_GetCurMemoryUsed()
#define GK_GRAPH_FMT_METIS
static struct gk_option long_options[]
Array< int, Dynamic, 1 > v
void gk_graph_ComputeBFSOrdering(gk_graph_t *graph, int v, int32_t **r_perm, int32_t **r_iperm)
idx_t idx_t idx_t idx_t idx_t * perm
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static char helpstr[][100]
char * gk_strdup(char *orgstr)
Duplicates a string.
char * gk_optarg
For communication arguments to the caller.
void reorder_centroid(params_t *params, gk_graph_t *graph, int32_t *perm)
void * gk_malloc(size_t nbytes, char *msg)
void gk_free(void **ptr1,...)
idx_t idx_t idx_t * adjncy
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.
void gk_graph_ComputeBestFOrdering(gk_graph_t *graph, int v, int type, int32_t **r_perm, int32_t **r_iperm)