46 const RCP<const typename Adapter::base_adapter_t> &adapter__,
47 const RCP<Teuchos::ParameterList> &pl__,
48 const RCP<
const Teuchos::Comm<int> > &comm__,
49 RCP<const Environment> &env__,
51 ) : adapter(adapter__), pl(pl__), comm(comm__), env(env__), graphFlags(graphFlags__)
67 ArrayView<const gno_t> edgeIds;
68 ArrayView<const offset_t> offsets;
69 ArrayView<StridedData<lno_t, scalar_t> > wgts;
72 const size_t nVtx = model->getLocalNumVertices();
73 model->getEdgeList(edgeIds, offsets, wgts);
74 const int numWeightsPerEdge = model->getNumWeightsPerEdge();
75 if (numWeightsPerEdge > 1){
76 throw std::runtime_error(
"Multiple weights not supported.");
81 cout <<
"Debug: Local graph from getLocalEdgeList" << endl;
82 cout <<
"rank " << comm->getRank() <<
": nVtx= " << nVtx << endl;
83 cout <<
"rank " << comm->getRank() <<
": edgeIds: " << edgeIds << endl;
84 cout <<
"rank " << comm->getRank() <<
": offsets: " << offsets << endl;
88 const ArrayRCP<lno_t> invPerm = solution->getPermutationRCP(
true);
89 const ArrayRCP<lno_t> tmpPerm(invPerm.size());
93 if (offsets[nVtx] == 0) {
94 for (
size_t i = 0; i < nVtx; ++i) {
97 solution->setHaveInverse(
true);
102 Tpetra::global_size_t
INVALID = Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
103 for (
size_t i = 0; i < nVtx; ++i) {
113 Teuchos::Array<std::pair<gno_t, offset_t> > children;
115 while (count < nVtx) {
119 while ((next < nVtx) && (
static_cast<Tpetra::global_size_t
>(invPerm[next]) !=
INVALID)) next++;
123 std::string root_method = pl->get(
"root_method",
"pseudoperipheral");
124 if (root_method == std::string(
"first"))
126 else if (root_method == std::string(
"smallest_degree"))
127 root = findSmallestDegree(next, nVtx, edgeIds, offsets);
128 else if (root_method == std::string(
"pseudoperipheral"))
129 root = findPseudoPeripheral(next, nVtx, edgeIds, offsets);
132 throw std::runtime_error(
"invalid root_method");
138 invPerm[root] = count++;
139 tmpPerm[invPerm[root]] = root;
149 for (
offset_t ptr = offsets[v]; ptr < offsets[v+1]; ++ptr){
150 gno_t child = edgeIds[ptr];
151 if (
static_cast<Tpetra::global_size_t
>(invPerm[child]) ==
INVALID){
153 std::pair<gno_t,offset_t> newchild;
154 newchild.first = child;
155 newchild.second = offsets[child+1] - offsets[child];
156 children.push_back(newchild);
164 typename Teuchos::Array<std::pair<gno_t,offset_t> >::iterator it = children.begin ();
165 for ( ; it != children.end(); ++it){
167 gno_t child = it->first;
168 invPerm[child] = count++;
169 tmpPerm[invPerm[child]] = child;
182 for (
size_t i=0; i < nVtx/2; ++i) {
189 invPerm[tmpPerm[nVtx-1-i]] = i;
190 invPerm[temp] = nVtx-1-i;
195 solution->setHaveInverse(
true);