81 const RCP<const typename Adapter::base_adapter_t> &adapter__,
82 const RCP<Teuchos::ParameterList> &pl__,
83 const RCP<
const Teuchos::Comm<int> > &comm__,
84 RCP<const Environment> &env__,
86 ) : adapter(adapter__), pl(pl__), comm(comm__), env(env__), graphFlags(graphFlags__)
95 int localOrder(
const RCP<LocalOrderingSolution<lno_t> > &solution)
102 ArrayView<const gno_t> edgeIds;
103 ArrayView<const offset_t> offsets;
104 ArrayView<StridedData<lno_t, scalar_t> > wgts;
106 const auto model = rcp(
new GraphModel<Adapter>(adapter, env, comm, graphFlags));
107 const size_t nVtx = model->getLocalNumVertices();
108 model->getEdgeList(edgeIds, offsets, wgts);
109 const int numWeightsPerEdge = model->getNumWeightsPerEdge();
110 if (numWeightsPerEdge > 1){
111 throw std::runtime_error(
"Multiple weights not supported.");
116 cout <<
"Debug: Local graph from getLocalEdgeList" << endl;
117 cout <<
"rank " << comm->getRank() <<
": nVtx= " << nVtx << endl;
118 cout <<
"rank " << comm->getRank() <<
": edgeIds: " << edgeIds << endl;
119 cout <<
"rank " << comm->getRank() <<
": offsets: " << offsets << endl;
123 const ArrayRCP<lno_t> invPerm = solution->getPermutationRCP(
true);
124 const ArrayRCP<lno_t> tmpPerm(invPerm.size());
128 if (offsets[nVtx] == 0) {
129 for (
size_t i = 0; i < nVtx; ++i) {
132 solution->setHaveInverse(
true);
137 Tpetra::global_size_t
INVALID = Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
138 for (
size_t i = 0; i < nVtx; ++i) {
148 Teuchos::Array<std::pair<gno_t, offset_t> > children;
150 while (count < nVtx) {
154 while ((next < nVtx) && (
static_cast<Tpetra::global_size_t
>(invPerm[next]) !=
INVALID)) next++;
158 std::string root_method = pl->get(
"root_method",
"pseudoperipheral");
159 if (root_method == std::string(
"first"))
161 else if (root_method == std::string(
"smallest_degree"))
162 root = findSmallestDegree(next, nVtx, edgeIds, offsets);
163 else if (root_method == std::string(
"pseudoperipheral"))
164 root = findPseudoPeripheral(next, nVtx, edgeIds, offsets);
167 throw std::runtime_error(
"invalid root_method");
173 invPerm[root] = count++;
174 tmpPerm[invPerm[root]] = root;
184 for (
offset_t ptr = offsets[v]; ptr < offsets[v+1]; ++ptr){
185 gno_t child = edgeIds[ptr];
186 if (
static_cast<Tpetra::global_size_t
>(invPerm[child]) ==
INVALID){
188 std::pair<gno_t,offset_t> newchild;
189 newchild.first = child;
190 newchild.second = offsets[child+1] - offsets[child];
191 children.push_back(newchild);
196 SortPairs<gno_t,offset_t> zort;
199 typename Teuchos::Array<std::pair<gno_t,offset_t> >::iterator it = children.begin ();
200 for ( ; it != children.end(); ++it){
202 gno_t child = it->first;
203 invPerm[child] = count++;
204 tmpPerm[invPerm[child]] = child;
217 for (
size_t i=0; i < nVtx/2; ++i) {
224 invPerm[tmpPerm[nVtx-1-i]] = i;
225 invPerm[temp] = nVtx-1-i;
230 solution->setHaveInverse(
true);