Go to the documentation of this file.
   24   idx_t i, 
j, 
k, 
l, fmt, 
ncon, nfields, readew, readvw, readvs, edge, ewgt;
 
   26   char *line=
NULL, fmtstr[256], *curstr, *newstr;
 
   41       errexit(
"Premature end of input file: file: %s\n", 
params->filename);
 
   42   } 
while (line[0] == 
'%');
 
   50     errexit(
"The input file does not specify the number of vertices and edges.\n");
 
   57     errexit(
"Cannot read this type of file format [fmt=%"PRIDX"]!\n", fmt);
 
   59   sprintf(fmtstr, 
"%03"PRIDX, fmt%1000);
 
   60   readvs = (fmtstr[0] == 
'1');
 
   61   readvw = (fmtstr[1] == 
'1');
 
   62   readew = (fmtstr[2] == 
'1');
 
   67   if (
ncon > 0 && !readvw) 
 
   69       "------------------------------------------------------------------------------\n" 
   70       "***  I detected an error in your input file  ***\n\n" 
   71       "You specified ncon=%"PRIDX", but the fmt parameter does not specify vertex weights\n"  
   72       "Make sure that the fmt parameter is set to either 10 or 11.\n" 
   73       "------------------------------------------------------------------------------\n", 
ncon);
 
   91         errexit(
"Premature end of input file while reading vertex %"PRIDX".\n", 
i+1);
 
   92     } 
while (line[0] == 
'%');
 
  100       if (newstr == curstr)
 
  101         errexit(
"The line for vertex %"PRIDX" does not have vsize information\n", 
i+1);
 
  112         if (newstr == curstr)
 
  113           errexit(
"The line for vertex %"PRIDX" does not have enough weights " 
  114                   "for the %"PRIDX" constraints.\n", 
i+1, 
ncon);
 
  122       edge = 
strtoidx(curstr, &newstr, 10);
 
  123       if (newstr == curstr)
 
  127       if (edge < 1 || edge > 
graph->nvtxs)
 
  132         ewgt = 
strtoidx(curstr, &newstr, 10);
 
  133         if (newstr == curstr)
 
  142         errexit(
"There are more edges in the file than the %"PRIDX" specified.\n", 
 
  154     printf(
"------------------------------------------------------------------------------\n");
 
  155     printf(
"***  I detected an error in your input file  ***\n\n");
 
  156     printf(
"In the first line of the file, you specified that the graph contained\n" 
  157            "%"PRIDX" edges. However, I only found %"PRIDX" edges in the file.\n", 
 
  159     if (2*
k == 
graph->nedges) {
 
  160       printf(
"\n *> I detected that you specified twice the number of edges that you have in\n");
 
  161       printf(
"    the file. Remember that the number of edges specified in the first line\n");
 
  162       printf(
"    counts each edge between vertices v and u only once.\n\n");
 
  164     printf(
"Please specify the correct number of edges in the first line of the file.\n");
 
  165     printf(
"------------------------------------------------------------------------------\n");
 
  182   size_t nlines, ntokens;
 
  183   char *line=
NULL, *curstr, *newstr;
 
  201       errexit(
"Premature end of input file: file: %s\n", 
params->filename);
 
  202   } 
while (line[0] == 
'%');
 
  209     errexit(
"The input file does not specify the number of elements.\n");
 
  212     errexit(
"The supplied number of elements:%"PRIDX" must be positive.\n", mesh->
ne);
 
  214   if (mesh->
ne > nlines)
 
  215     errexit(
"The file has %zu lines which smaller than the number of " 
  216             "elements of %"PRIDX" specified in the header line.\n", nlines, mesh->
ne);
 
  230         errexit(
"Premature end of input file while reading element %"PRIDX".\n", 
i+1);
 
  231     } 
while (line[0] == 
'%');
 
  239       if (newstr == curstr)
 
  240         errexit(
"The line for vertex %"PRIDX" does not have enough weights " 
  241                 "for the %"PRIDX" constraints.\n", 
i+1, 
ncon);
 
  248       node = 
strtoidx(curstr, &newstr, 10);
 
  249       if (newstr == curstr)
 
  277   idx_t i, 
j, from, to, fromcnum, tocnum, nleft;
 
  279   char *line=
NULL, *curstr, *newstr;
 
  294     errexit(
"Graph file %s does not exist!\n", 
params->tpwgtsfile);
 
  296   fpin = 
gk_fopen(
params->tpwgtsfile, 
"r", 
"ReadTPwgts: tpwgtsfile");
 
  298   while (
gk_getline(&line, &lnlen, fpin) != -1) {
 
  305     from = 
strtoidx(curstr, &newstr, 10);
 
  306     if (newstr == curstr)
 
  307       errexit(
"The 'from' component of line <%s> in the tpwgts file is incorrect.\n", line);
 
  310     if (curstr[0] == 
'-') {
 
  311       to = 
strtoidx(curstr+1, &newstr, 10);
 
  312       if (newstr == curstr)
 
  313         errexit(
"The 'to' component of line <%s> in the tpwgts file is incorrect.\n", line);
 
  320     if (curstr[0] == 
':') {
 
  321       fromcnum = 
strtoidx(curstr+1, &newstr, 10);
 
  322       if (newstr == curstr)
 
  323         errexit(
"The 'fromcnum' component of line <%s> in the tpwgts file is incorrect.\n", line);
 
  326       if (curstr[0] == 
'-') {
 
  327         tocnum = 
strtoidx(curstr+1, &newstr, 10);
 
  328         if (newstr == curstr)
 
  329           errexit(
"The 'tocnum' component of line <%s> in the tpwgts file is incorrect.\n", line);
 
  341     if (curstr[0] == 
'=') {
 
  343       if (newstr == curstr)
 
  344         errexit(
"The 'wgt' component of line <%s> in the tpwgts file is incorrect.\n", line);
 
  348       errexit(
"The 'wgt' component of line <%s> in the tpwgts file is missing.\n", line);
 
  354     if (from < 0 || to < 0 || from >= 
params->nparts || to >= 
params->nparts)
 
  356     if (fromcnum < 0 || tocnum < 0 || fromcnum >= 
ncon || tocnum >= 
ncon)
 
  359     if (awgt <= 0.0 || awgt >= 1.0)
 
  361     for (
i=from; 
i<=to; 
i++) {
 
  362       for (
j=fromcnum; 
j<=tocnum; 
j++)
 
  372     for (twgt=0.0, nleft=
params->nparts, 
i=0; i<params->
nparts; 
i++) {
 
  386         errexit(
"The total specified target partition weights for constraint #%"PRIDX 
  387                 " of %"PRREAL" exceeds 1.0.\n", 
j, twgt);
 
  389       awgt = (1.0 - twgt)/nleft;
 
  414     if (fscanf(fpin, 
"%"SCIDX"\n", vector+
i) != 1)
 
  415       errexit(
"[%s] Premature end of file %s at line %d [nvtxs: %d]\n",
 
  483   sprintf(
filename, 
"%s.iperm", fname);
 
  501   int hasvwgt=0, hasewgt=0, hasvsize=0;
 
  504   nvtxs  = 
graph->nvtxs;
 
  522     for (
i=0; 
i<nvtxs; 
i++) {
 
  530     for (
i=0; 
i<
xadj[nvtxs]; 
i++) {
 
  542   if (hasvwgt || hasvsize || hasewgt) {
 
  543     fprintf(fpout, 
" %d%d%d", hasvsize, hasvwgt, hasewgt);
 
  545       fprintf(fpout, 
" %d", (
int)
graph->ncon);
 
  550   for (
i=0; 
i<nvtxs; 
i++) {
 
  551     fprintf(fpout, 
"\n");
 
  
void WritePermutation(char *fname, idx_t *iperm, idx_t n)
void WriteGraph(graph_t *graph, char *filename)
idx_t idx_t idx_t idx_t idx_t idx_t * adjwgt
void gk_free(void **ptr1,...)
idx_t idx_t idx_t idx_t idx_t * vsize
idx_t idx_t idx_t * adjncy
void errexit(char *f_str,...)
FILE * gk_fopen(char *, char *, const char *)
void WriteMeshPartition(char *fname, idx_t nparts, idx_t ne, idx_t *epart, idx_t nn, idx_t *npart)
static const SmartProjectionParams params
graph_t * ReadGraph(params_t *params)
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t idx_t * npart
char * gk_strchr_replace(char *str, char *fromlist, char *tolist)
Replaces certain characters in a string.
idx_t idx_t idx_t idx_t idx_t idx_t idx_t * nparts
idx_t idx_t idx_t idx_t idx_t idx_t * iperm
static const Line3 l(Rot3(), 1, 1)
void ReadPOVector(graph_t *graph, char *filename, idx_t *vector)
void gk_getfilestats(char *fname, size_t *r_nlines, size_t *r_ntokens, size_t *r_max_nlntokens, size_t *r_nbytes)
idx_t idx_t idx_t idx_t * vwgt
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t idx_t idx_t * part
void ReadTPwgts(params_t *params, idx_t ncon)
int gk_fexists(char *fname)
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t * epart
gk_idx_t gk_getline(char **lineptr, size_t *n, FILE *stream)
NonlinearFactorGraph graph
mesh_t * ReadMesh(params_t *params)
static constexpr double k
void WritePartition(char *fname, idx_t *part, idx_t n, idx_t nparts)
gtsam
Author(s): 
autogenerated on Wed May 28 2025 03:01:31