36 idx_t minedge, maxedge, minewgt, maxewgt;
39 numflag = (numflag == 0 ? 0 : 1);
48 htable =
ismalloc(nvtxs, 0,
"htable");
50 minedge = maxedge = adjncy[0];
51 minewgt = maxewgt = adjwgt[0];
53 for (i=0; i<nvtxs; i++) {
54 for (j=xadj[i]; j<xadj[i+1]; j++) {
57 minedge = (k < minedge) ? k : minedge;
58 maxedge = (k > maxedge) ? k : maxedge;
59 minewgt = (adjwgt[
j] < minewgt) ? adjwgt[j] : minewgt;
60 maxewgt = (adjwgt[
j] > maxewgt) ? adjwgt[j] : maxewgt;
64 printf(
"Vertex %"PRIDX" contains a self-loop " 65 "(i.e., diagonal entry in the matrix)!\n", i+numflag);
69 for (l=xadj[k]; l<xadj[k+1]; l++) {
71 if (adjwgt[l] != adjwgt[j]) {
75 "do not have the same weight!\n",
76 i+numflag, k+numflag, adjwgt[j],
77 k+numflag, i+numflag, adjwgt[l]);
85 printf(
"Missing edge: (%"PRIDX" %"PRIDX")!\n", k+numflag, i+numflag);
95 printf(
"Edge %"PRIDX" from vertex %"PRIDX" is repeated %"PRIDX" times\n",
96 k+numflag, i+numflag, htable[k]++);
101 for (j=xadj[i]; j<xadj[i+1]; j++)
102 htable[adjncy[j]] = 0;
106 if (err > 0 && verbose) {
107 printf(
"A total of %"PRIDX" errors exist in the input file. " 108 "Correct them, and run again!\n", err);
113 return (err == 0 ? 1 : 0);
126 printf(
"Input Error: ncon must be >= 1.\n");
131 for (i=ncon*nvtxs; i>=0; i--) {
133 printf(
"Input Error: negative vertex weight(s).\n");
139 for (i=nvtxs; i>=0; i--) {
141 printf(
"Input Error: negative vertex sizes(s).\n");
147 for (i=xadj[nvtxs]-1; i>=0; i--) {
149 printf(
"Input Error: non-positive edge weight(s).\n");
180 idx_t *nxadj, *nadjncy, *nadjwgt;
185 nvtxs = graph->
nvtxs;
193 ngraph->
nvtxs = nvtxs;
207 for (nedges=0, i=0; i<nvtxs; i++) {
208 for (j=xadj[i]; j<xadj[i+1]; j++) {
212 edges[nedges].
v = adjncy[
j];
213 edges[nedges].
w = adjwgt[
j];
216 else if (i > adjncy[j]) {
217 edges[nedges].
u = adjncy[
j];
219 edges[nedges].
w = adjwgt[
j];
229 for (k=0, i=1; i<nedges; i++) {
230 if (edges[k].
v != edges[i].
v || edges[k].u != edges[i].u) {
231 edges[++k] = edges[
i];
237 nxadj = ngraph->
xadj =
ismalloc(nvtxs+1, 0,
"FixGraph: nxadj");
238 nadjncy = ngraph->
adjncy =
imalloc(2*nedges,
"FixGraph: nadjncy");
239 nadjwgt = ngraph->
adjwgt =
imalloc(2*nedges,
"FixGraph: nadjwgt");
243 for (k=0; k<nedges; k++) {
249 for (k=0; k<nedges; k++) {
250 nadjncy[nxadj[edges[k].
u]] = edges[k].v;
251 nadjncy[nxadj[edges[k].v]] = edges[k].u;
252 nadjwgt[nxadj[edges[k].u]] = edges[k].w;
253 nadjwgt[nxadj[edges[k].v]] = edges[k].w;
idx_t idx_t idx_t idx_t * vwgt
vector< MFAS::KeyPair > edges
graph_t * FixGraph(graph_t *graph)
int CheckGraph(graph_t *graph, int numflag, int verbose)
NonlinearFactorGraph graph
idx_t idx_t idx_t idx_t idx_t * vsize
#define ASSERT(expression)
static const Line3 l(Rot3(), 1, 1)
idx_t idx_t idx_t idx_t idx_t * numflag
#define SHIFTCSR(i, n, a)
idx_t idx_t idx_t idx_t idx_t idx_t * adjwgt
void * gk_malloc(size_t nbytes, char *msg)
void gk_free(void **ptr1,...)
idx_t idx_t idx_t * adjncy
int CheckInputGraphWeights(idx_t nvtxs, idx_t ncon, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt)