Zoltan2  Version of the Day
GraphModel.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 //
46 // Testing of GraphModel built from Xpetra matrix input adapters.
47 //
48 
58 #include <Zoltan2_GraphModel.hpp>
60 #include <Zoltan2_TestHelpers.hpp>
61 
62 #include <string>
63 #include <vector>
64 #include <iostream>
65 #include <bitset>
66 
67 #include <Teuchos_Comm.hpp>
68 #include <Teuchos_DefaultComm.hpp>
69 #include <Teuchos_ArrayView.hpp>
70 
71 using namespace std;
72 using Teuchos::RCP;
73 using Teuchos::rcp;
74 using Teuchos::Comm;
75 using Teuchos::DefaultComm;
76 using Teuchos::ArrayView;
77 
78 typedef Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> tcrsMatrix_t;
79 typedef Tpetra::Map<lno_t, gno_t, node_t> tmap_t;
81 
82 using std::string;
83 using std::vector;
84 
85 void printGraph(lno_t nrows, const gno_t *v, const lno_t *elid,
86  const gno_t *egid,
87  const int *owner, const lno_t *idx, const RCP<const Comm<int> > &comm)
88 {
89  int rank = comm->getRank();
90  int nprocs = comm->getSize();
91  comm->barrier();
92  if (rank == 0){
93  if (owner)
94  std::cout << "Global graph:" << std::endl;
95  else
96  std::cout << "Local graph:" << std::endl;
97  }
98 
99  for (int p=0; p < nprocs; p++){
100  if (p == rank){
101  std::cout << "Rank " << p << std::endl;
102  if (owner){
103  for (lno_t i=0; i < nrows; i++){
104  std::cout << " Vtx " << *v++ << ": ";
105  if (elid)
106  for (lno_t j=idx[i]; j < idx[i+1]; j++)
107  std::cout << *elid++ << " (" << *owner++ << ") ";
108  else
109  for (lno_t j=idx[i]; j < idx[i+1]; j++)
110  std::cout << *egid++ << " (" << *owner++ << ") ";
111  std::cout << std::endl;
112  }
113  std::cout.flush();
114  }
115  else{
116  for (lno_t i=0; i < nrows; i++){
117  std::cout << " Vtx " << i << ": ";
118  if (elid)
119  for (lno_t j=idx[i]; j < idx[i+1]; j++)
120  std::cout << *elid++ << " ";
121  else
122  for (lno_t j=idx[i]; j < idx[i+1]; j++)
123  std::cout << *egid++ << " ";
124  std::cout << std::endl;
125  }
126  std::cout.flush();
127  }
128  }
129  comm->barrier();
130  }
131  comm->barrier();
132 }
133 
134 void testMatrixInput(RCP<const Tpetra::CrsMatrix<scalar_t, lno_t, gno_t> > &M,
135  const RCP<const Comm<int> > &comm,
136  bool idsAreConsecutive,
137  int rowWeightDim, int nnzDim, int coordDim,
138  bool consecutiveIdsRequested, bool removeSelfEdges)
139 {
140  int fail=0;
141  int rank = comm->getRank();
142  int nprocs = comm->getSize();
143  RCP<const Zoltan2::Environment> env = rcp(new Zoltan2::Environment);
144 
145  lno_t nLocalRows = M->getNodeNumRows();
146  lno_t nLocalNZ = M->getNodeNumEntries();
147  gno_t nGlobalRows = M->getGlobalNumRows();
148  gno_t nGlobalNZ = M->getGlobalNumEntries();
149 
150  // Create a matrix input adapter.
151 
152  typedef Zoltan2::MatrixInput<tcrsMatrix_t> base_adapter_t;
154 
155  std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags;
156  if (consecutiveIdsRequested)
158  if (removeSelfEdges)
159  modelFlags.set(Zoltan2::SELF_EDGES_MUST_BE_REMOVED);
160 
161  scalar_t **coords=NULL;
162  scalar_t **rowWeights=NULL;
163 
164  if (coordDim > 0){
165  coords = new scalar_t * [coordDim];
166  for (int i=0; i < coordDim; i++){
167  coords[i] = new scalar_t [nLocalRows];
168  for (lno_t j=0; j < nLocalRows; j++){
169  coords[i][j] = 100000*i + j;
170  }
171  }
172  }
173 
174  if (rowWeightDim > 0){
175  rowWeights = new scalar_t * [rowWeightDim];
176  for (int i=0; i < rowWeightDim; i++){
177  if (nnzDim == i)
178  rowWeights[i] = NULL;
179  else{
180  rowWeights[i] = new scalar_t [nLocalRows];
181  for (lno_t j=0; j < nLocalRows; j++){
182  rowWeights[i][j] = 200000*i + j;
183  }
184  }
185  }
186  }
187 
188  adapter_t tmi(M, coordDim, rowWeightDim);
189 
190  for (int i=0; i < rowWeightDim; i++){
191  if (nnzDim == i)
192  tmi.setRowWeightIsNumberOfNonZeros(i);
193  else
194  tmi.setRowWeights(i, rowWeights[i], 1);
195  }
196 
197  for (int i=0; i < coordDim; i++){
198  tmi.setRowCoordinates(i, coords[i], 1);
199  }
200 
201  int numLocalDiags = M->getNodeNumDiags();
202  int numGlobalDiags = M->getGlobalNumDiags();
203 
204  const RCP<const tmap_t> rowMap = M->getRowMap();
205  const RCP<const tmap_t> colMap = M->getColMap();
206 
207  // How many neighbor vertices are not on my process.
208 
209  // we know GIDs are consecutive
210  int minLocalGID = rowMap->getMinGlobalIndex();
211  int maxLocalGID = rowMap->getMaxGlobalIndex();
212 
213  int *numNbors = new int [nLocalRows];
214  int *numLocalNbors = new int [nLocalRows];
215  bool *haveDiag = new bool [nLocalRows];
216  gno_t totalLocalNbors = 0;
217 
218  for (lno_t i=0; i < nLocalRows; i++){
219  numLocalNbors[i] = 0;
220  haveDiag[i] = false;
221  ArrayView<const lno_t> idx;
222  ArrayView<const scalar_t> val;
223  M->getLocalRowView(i, idx, val);
224  numNbors[i] = idx.size();
225 
226  for (lno_t j=0; j < idx.size(); j++){
227  if (idx[j] == i){
228  haveDiag[i] = true;
229  }
230  else{
231  gno_t gidVal = colMap->getGlobalElement(idx[j]);
232  if (gidVal >= minLocalGID && gidVal <= maxLocalGID){
233  numLocalNbors[i]++;
234  totalLocalNbors++;
235  }
236  }
237  }
238  }
239 
240  // Create a GraphModel based on this input data.
241 
243  const base_adapter_t *baseTmi = &tmi;
244 
245  try{
246  model = new Zoltan2::GraphModel<base_adapter_t>(baseTmi, env,
247  comm, modelFlags);
248  }
249  catch (std::exception &e){
250  std::cerr << rank << ") " << e.what() << std::endl;
251  fail = 1;
252  }
253  TEST_FAIL_AND_EXIT(*comm, !fail, "Creating xpetra graph model", 1)
254 
255  // Test the GraphModel interface
256 
257  if (model->getLocalNumVertices() != size_t(nLocalRows))
258  fail = 1;
259  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalNumVertices", 1)
260 
261  if (model->getGlobalNumVertices() != size_t(nGlobalRows))
262  fail = 1;
263  TEST_FAIL_AND_EXIT(*comm, !fail, "getGlobalNumVertices", 1)
264 
265  size_t num = (removeSelfEdges ? (nLocalNZ-numLocalDiags) : nLocalNZ);
266 
267  if (model->getLocalNumGlobalEdges() != num)
268  fail = 1;
269  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalNumGlobalEdges", 1)
270 
271  num = totalLocalNbors;
272  if (!removeSelfEdges){
273  for (lno_t i=0; i < nLocalRows; i++)
274  if (haveDiag[i])
275  num++;
276  }
277 
278  if (model->getLocalNumLocalEdges() != num)
279  fail = 1;
280  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalNumLocalEdges", 1)
281 
282  num = (removeSelfEdges ? (nGlobalNZ-numGlobalDiags) : nGlobalNZ);
283 
284  if (model->getGlobalNumEdges() != num)
285  fail = 1;
286  TEST_FAIL_AND_EXIT(*comm, !fail, "getGlobalNumEdges", 1)
287 
288  if (model->getVertexWeightDim() != rowWeightDim)
289  fail = 1;
290  TEST_FAIL_AND_EXIT(*comm, !fail, "getVertexWeightDim", 1)
291 
292  if (model->getEdgeWeightDim() != 0)
293  fail = 1;
294  TEST_FAIL_AND_EXIT(*comm, !fail, "getEdgeWeightDim", 1)
295 
296  if (model->getCoordinateDim() != coordDim)
297  fail = 1;
298  TEST_FAIL_AND_EXIT(*comm, !fail, "getCoordinateDim", 1)
299 
300  ArrayView<const gno_t> vertexGids;
301  ArrayView<input_t> crds;
302  ArrayView<input_t> wgts;
303 
304  try{
305  model->getVertexList(vertexGids, crds, wgts);
306  }
307  catch (std::exception &e){
308  std::cerr << rank << ") Error " << e.what() << std::endl;
309  fail = 1;
310  }
311  TEST_FAIL_AND_EXIT(*comm, !fail, "getVertexList", 1)
312 
313  if (vertexGids.size() != nLocalRows)
314  fail = 1;
315  TEST_FAIL_AND_EXIT(*comm, !fail, "getVertexList", 1)
316 
317  // We know model stores things in same order we gave it.
318 
319  if (idsAreConsecutive){
320  for (lno_t i=0; i < nLocalRows; i++){
321  if (vertexGids[i] != minLocalGID + i) {
322  fail = 1;
323  break;
324  }
325  }
326  }
327  else{ // round robin ids
328  gno_t myGid = rank;
329  for (lno_t i=0; i < nLocalRows; i++, myGid += nprocs){
330  if (vertexGids[i] != myGid){
331  fail = 1;
332  break;
333  }
334  }
335  }
336 
337  TEST_FAIL_AND_EXIT(*comm, !fail, "vertex gids", 1)
338 
339  if ((crds.size() != coordDim) || (wgts.size() != rowWeightDim))
340  fail = 1;
341  TEST_FAIL_AND_EXIT(*comm, !fail, "coord or weight array size", 1)
342 
343  for (int i=0; !fail && i < coordDim; i++){
344  for (lno_t j=0; j < nLocalRows; j++){
345  if (crds[i][j] != 200000*i + j){
346  fail = 1;
347  break;
348  }
349  }
350  }
351  TEST_FAIL_AND_EXIT(*comm, !fail, "coord values", 1)
352 
353  for (int i=0; !fail && i < rowWeightDim; i++){
354  if (nnzDim == i){
355  for (lno_t j=0; j < nLocalRows; j++){
356  scalar_t val = numNbors[j];
357  if (removeSelfEdges && haveDiag[j])
358  val -= 1;
359  if (wgts[i][j] != val){
360  fail = 1;
361  break;
362  }
363  }
364  }
365  else{
366  for (lno_t j=0; j < nLocalRows; j++){
367  if (wgts[i][j] != 100000*i + j){
368  fail = 1;
369  break;
370  }
371  }
372  }
373  }
374 
375  TEST_FAIL_AND_EXIT(*comm, !fail, "row weight values", 1)
376 
377  ArrayView<const gno_t> edgeGids;
378  ArrayView<const int> procIds;
379  ArrayView<const lno_t> offsets;
380  size_t numEdges=0;
381 
382  try{
383  numEdges = model->getEdgeList(edgeGids, procIds, offsets, wgts);
384  }
385  catch(std::exception &e){
386  std::cerr << rank << ") Error " << e.what() << std::endl;
387  fail = 1;
388  }
389  TEST_FAIL_AND_EXIT(*comm, !fail, "getEdgeList", 1)
390 
391  TEST_FAIL_AND_EXIT(*comm, wgts.size() == 0, "edge weights present", 1)
392 
393  num = 0;
394  for (ArrayView<const lno_t>::size_type i=0; i < offsets.size()-1; i++){
395  size_t edgeListSize = offsets[i+1] - offsets[i];
396  num += edgeListSize;
397  size_t val = numNbors[i];
398  if (removeSelfEdges && haveDiag[i])
399  val--;
400  if (edgeListSize != val){
401  fail = 1;
402  break;
403  }
404  }
405 
406  TEST_FAIL_AND_EXIT(*comm, numEdges==num, "getEdgeList size", 1)
407 
408  if (nGlobalRows < 200){
409  printGraph(nLocalRows, vertexGids.getRawPtr(), NULL,
410  edgeGids.getRawPtr(), procIds.getRawPtr(), offsets.getRawPtr(), comm);
411  }
412  else{
413  if (rank==0)
414  std::cout << " " << nGlobalRows << " total rows" << std::endl;
415  }
416 
417  // Get graph restricted to this process
418 
419  ArrayView<const lno_t> localEdges;
420  ArrayView<const lno_t> localOffsets;
421  size_t numLocalNeighbors=0;
422 
423  try{
424  numLocalNeighbors= model->getLocalEdgeList(localEdges, localOffsets, wgts);
425  }
426  catch(std::exception &e){
427  std::cerr << rank << ") Error " << e.what() << std::endl;
428  fail = 1;
429  }
430  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalEdgeList", 1)
431 
432 #ifdef THIS_CODE_DOESNT_FAIL
433  num = 0;
434  for (size_t i=0; i < localOffsets.size()-1; i++){
435  size_t edgeListSize = localOffsets[i+1] - localOffsets[i];
436  num += edgeListSize;
437  size_t val = numLocalNbors[i];
438  if (removeSelfEdges && haveDiag[i])
439  val--;
440  if (edgeListSize != val){
441  fail = 1;
442  break;
443  }
444  }
445  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalEdgeList list sizes", 1)
446 
447  TEST_FAIL_AND_EXIT(*comm, numLocalNeighbors==num, "getLocalEdgeList size", 1)
448 
449  if (size_t(totalLocalNbors) != numLocalNeighbors)
450  fail = 1;
451 
452  TEST_FAIL_AND_EXIT(*comm, !fail, "getLocalEdgeList size", 1)
453 
454  if (nGlobalRows < 200){
455  if (totalLocalNbors == 0){
456  if (rank == 0)
457  std::cout << " Graph of local edges is empty" << std::endl;
458  }
459  else{
460  printGraph(nLocalRows, vertexGids.getRawPtr(),
461  localEdges.getRawPtr(), NULL, NULL, localOffsets.getRawPtr(), comm);
462  }
463  }
464 #endif
465 
466  delete model;
467 
468  if (nLocalRows){
469  delete [] numNbors;
470  delete [] numLocalNbors;
471  delete [] haveDiag;
472 
473  if (rowWeightDim > 0){
474  for (int i=0; i < rowWeightDim; i++){
475  if (rowWeights[i])
476  delete [] rowWeights[i];
477  }
478  delete [] rowWeights;
479  }
480 
481  if (coordDim > 0){
482  for (int i=0; i < coordDim; i++){
483  if (coords[i])
484  delete [] coords[i];
485  }
486  delete [] coords;
487  }
488  }
489 
490  if (rank==0) std::cout << " OK" << std::endl;
491 }
492 
493 void testGraphModel(string fname, gno_t xdim, gno_t ydim, gno_t zdim,
494  const RCP<const Comm<int> > &comm,
495  int rowWeightDim, int nnzDim, int coordDim,
496  bool consecutiveIdsRequested, bool removeSelfEdges)
497 {
498  int rank = comm->getRank();
499 
500  if (rank==0){
501  cout << endl << "=======================" << endl;
502  if (fname.size() > 0)
503  cout << endl << "Test parameters: file name " << fname << endl;
504  else{
505  cout << endl << "Test parameters: dimension ";
506  cout << xdim << "x" << ydim << "x" << zdim << endl;
507  }
508 
509  cout << "Vertex weight dim: " << rowWeightDim << endl;
510  if (nnzDim >= 0)
511  cout << " Dimension " << nnzDim << " is number of neighbors" << endl;
512 
513  cout << "Coordinate dim: " << coordDim << endl;
514  cout << "Request consecutive vertex gids: ";
515  cout << (consecutiveIdsRequested ? "yes" : "no") << endl;
516  cout << "Request to remove self edges: ";
517  cout << (removeSelfEdges ? "yes" : "no") << endl;
518  }
519 
520  typedef Tpetra::CrsMatrix<scalar_t, lno_t, gno_t, node_t> tcrsMatrix_t;
521 
522  // Input generator
523  UserInputForTests *input;
524 
525  if (fname.size() > 0)
526  input = new UserInputForTests(testDataFilePath, fname, comm, true);
527  else
528  input = new UserInputForTests(xdim,ydim,zdim,string(""), comm, true);
529 
530  RCP<tcrsMatrix_t> M = input->getTpetraCrsMatrix();
531 
532  // Row Ids of test input are already consecutive
533 
534  RCP<const tcrsMatrix_t> Mconsec = rcp_const_cast<const tcrsMatrix_t>(M);
535 
536  RCP<const Tpetra::CrsGraph<lno_t, gno_t> > graph = Mconsec->getCrsGraph();
537 
538  printTpetraGraph<lno_t, gno_t>(comm, *graph, cout, 100,
539  "Graph with consecutive IDs");
540 
541  bool idsAreConsecutive = true;
542 
543  testMatrixInput(Mconsec, comm, idsAreConsecutive,
544  rowWeightDim, nnzDim, coordDim,
545  consecutiveIdsRequested, removeSelfEdges);
546 
547 #if 0
548  testGraphInput(Mconsec, comm, idsAreConsecutive,
549  rowWeightDim, nnzDim, coordDim,
550  consecutiveIdsRequested, removeSelfEdges);
551 #endif
552 
553  // Do a round robin migration so that global IDs are not consecutive.
554 
555 #ifdef TODO_THESE_HAVE_BEEN_TESTED
556  Array<gno_t> myNewRows;
557  for (size_t i=rank; i < Mconsec->getGlobalNumRows(); i+=nprocs)
558  myNewRows.push_back(i);
559 
560  RCP<const tcrsMatrix_t> Mnonconsec =
562  Mconsec, myNewRows.size(), myNewRows.getRawPtr());
563 
564  graph = Mnonconsec->getCrsGraph();
565 
566  printTpetraGraph<lno_t, gno_t>(comm, *graph, cout, 100,
567  "Graph with non-consecutive IDs");
568 
569  idsAreConsecutive = false;
570 
571  testMatrixInput(Mnonconsec, comm, idsAreConsecutive,
572  rowWeightDim, nnzDim, coordDim,
573  consecutiveIdsRequested, removeSelfEdges);
574 
575 #if 0
576  testGraphInput(Mnonconsec, comm, idsAreConsecutive,
577  rowWeightDim, nnzDim, coordDim,
578  consecutiveIdsRequested, removeSelfEdges);
579 #endif
580 
581 #endif
582 
583  delete input;
584 }
585 
586 int main(int argc, char *argv[])
587 {
588  Teuchos::GlobalMPISession session(&argc, &argv);
589  Teuchos::RCP<const Teuchos::Comm<int> > comm =
590  Teuchos::DefaultComm<int>::getComm();
591 
592  int rank = comm->getRank();
593 
594  int rowWeightDim=0;
595  int nnzDim = -1;
596  int coordDim=0;
597  bool consecutiveIdsRequested=false, removeSelfEdges=false;
598  string fname("simple");
599 
600  testGraphModel(fname, 0, 0, 0, comm,
601  rowWeightDim, nnzDim, coordDim,
602  consecutiveIdsRequested, removeSelfEdges);
603 
604 #ifdef TODO_THESE_HAVE_BEEN_TESTED
605  rowWeightDim = 1;
606 
607  testGraphModel(fname, 0, 0, 0, comm,
608  rowWeightDim, nnzDim, coordDim,
609  consecutiveIdsRequested, removeSelfEdges);
610 
611  nnzDim = 1;
612 
613  testGraphModel(fname, 0, 0, 0, comm,
614  rowWeightDim, nnzDim, coordDim,
615  consecutiveIdsRequested, removeSelfEdges);
616 
617  rowWeightDim = 2;
618  coordDim = 3;
619 
620  testGraphModel(fname, 0, 0, 0, comm,
621  rowWeightDim, nnzDim, coordDim,
622  consecutiveIdsRequested, removeSelfEdges);
623 
624  consecutiveIdsRequested = true;
625 
626  testGraphModel(fname, 0, 0, 0, comm,
627  rowWeightDim, nnzDim, coordDim,
628  consecutiveIdsRequested, removeSelfEdges);
629 
630  removeSelfEdges = true;
631 
632  testGraphModel(fname, 0, 0, 0, comm,
633  rowWeightDim, nnzDim, coordDim,
634  consecutiveIdsRequested, removeSelfEdges);
635 
636  consecutiveIdsRequested = false;
637 
638  testGraphModel(fname, 0, 0, 0, comm,
639  rowWeightDim, nnzDim, coordDim,
640  consecutiveIdsRequested, removeSelfEdges);
641 #endif
642 
643  if (rank==0)
644  cout << "PASS" << endl;
645 
646  return 0;
647 }
648 
int getEdgeWeightDim() const
Returns the dimension (0 or greater) of edge weights.
Defines the XpetraCrsMatrixInput adapter class.
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
int getVertexWeightDim() const
Returns the dimension (0 or greater) of vertex weights.
size_t getLocalNumLocalEdges() const
Returns the number of local edges on this process. Does not include edges to off-process vertices...
Zoltan2::StridedData< lno_t, scalar_t > input_t
Definition: GraphModel.cpp:80
size_t getLocalNumGlobalEdges() const
Returns the number of global edges on this process. Includes remote edges.
algorithm requires consecutive ids
void printGraph(lno_t nrows, const gno_t *v, const lno_t *elid, const gno_t *egid, const int *owner, const lno_t *idx, const RCP< const Comm< int > > &comm)
Definition: GraphModel.cpp:85
void testMatrixInput(RCP< const Tpetra::CrsMatrix< scalar_t, lno_t, gno_t > > &M, const RCP< const Comm< int > > &comm, bool idsAreConsecutive, int rowWeightDim, int nnzDim, int coordDim, bool consecutiveIdsRequested, bool removeSelfEdges)
Definition: GraphModel.cpp:134
A class that generates typical user input for testing.
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
Tpetra::Map< lno_t, gno_t, node_t > tmap_t
Definition: GraphModel.cpp:79
common code used by tests
size_t getGlobalNumVertices() const
Returns the global number vertices.
Tpetra::CrsMatrix< scalar_t, lno_t, gno_t, node_t > tcrsMatrix_t
Definition: GraphModel.cpp:78
size_t getEdgeList(ArrayView< const gno_t > &edgeIds, ArrayView< const int > &procIds, ArrayView< const lno_t > &offsets, ArrayView< input_t > &wgts) const
Sets pointers to this process&#39; edge (neighbor) global Ids, including off-process edges.
void testGraphModel(string fname, gno_t xdim, gno_t ydim, gno_t zdim, const RCP< const Comm< int > > &comm, int rowWeightDim, int nnzDim, int coordDim, bool consecutiveIdsRequested, bool removeSelfEdges)
Definition: GraphModel.cpp:493
int getCoordinateDim() const
Returns the dimension (0 to 3) of vertex coordinates.
int main(int argc, char *argv[])
Definition: GraphModel.cpp:586
RCP< tcrsMatrix_t > getTpetraCrsMatrix()
size_t getGlobalNumEdges() const
Returns the global number edges.
The StridedData class manages lists of weights or coordinates.
static RCP< const User > doMigration(const RCP< const User > &from, lno_t numLocalRows, const gno_t *myNewRows)
Migrate the object Given a user object and a new row distribution, create and return a new user objec...
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
MatrixInput defines the interface for input adapters for matrices.
size_t getLocalNumVertices() const
Returns the number vertices on this process.
double scalar_t
size_t getLocalEdgeList(ArrayView< const lno_t > &edgeIds, ArrayView< const lno_t > &offsets, ArrayView< input_t > &wgts)
Sets pointers to this process&#39; local-only edge (neighbor) LNOs, using the same implied vertex LNOs re...
GraphModel defines the interface required for graph models.
algorithm requires no self edges
Defines the GraphModel interface.
size_t getVertexList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &xyz, ArrayView< input_t > &wgts) const
Sets pointers to this process&#39; vertex Ids and their weights.
std::string testDataFilePath(".")