Zoltan2
Toggle main menu visibility
Loading...
Searching...
No Matches
Zoltan2_AlgSortedDegree.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Zoltan2: A package of combinatorial algorithms for scientific computing
4
//
5
// Copyright 2012 NTESS and the Zoltan2 contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef _ZOLTAN2_SORTEDDEGREE_HPP_
11
#define _ZOLTAN2_SORTEDDEGREE_HPP_
12
13
#include <
Zoltan2_Algorithm.hpp
>
14
#include <
Zoltan2_GraphModel.hpp
>
15
#include <
Zoltan2_OrderingSolution.hpp
>
16
#include <
Zoltan2_Sort.hpp
>
17
#include <algorithm>
18
19
24
25
namespace
Zoltan2
{
26
27
template
<
typename
Adapter>
28
class
AlgSortedDegree
:
public
Algorithm
<Adapter>
29
{
30
private
:
31
32
const
RCP<const typename Adapter::base_adapter_t> adapter;
33
const
RCP<Teuchos::ParameterList> pl;
34
const
RCP<const Teuchos::Comm<int> > comm;
35
RCP<const Environment> env;
36
modelFlag_t
graphFlags;
37
38
public
:
39
40
typedef
typename
Adapter::lno_t
lno_t
;
41
typedef
typename
Adapter::gno_t
gno_t
;
42
typedef
typename
Adapter::offset_t
offset_t
;
43
typedef
typename
Adapter::scalar_t
scalar_t
;
44
45
AlgSortedDegree
(
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__,
50
const
modelFlag_t
&graphFlags__
51
) : adapter(adapter__), pl(pl__), comm(comm__), env(env__), graphFlags(graphFlags__)
52
{
53
}
54
55
int
globalOrder
(
const
RCP<
GlobalOrderingSolution<gno_t>
> &
/* solution */
)
56
{
57
throw
std::logic_error(
58
"AlgSortedDegree does not yet support global ordering."
);
59
}
60
61
int
localOrder
(
const
RCP<
LocalOrderingSolution<lno_t>
> &solution)
62
{
63
int
ierr= 0;
64
65
HELLO
;
66
67
lno_t
*perm = solution->getPermutationView();
68
if
(perm==0){
69
// Throw exception
70
std::cerr <<
"perm is NULL"
<< std::endl;
71
ierr = -1;
72
}
73
74
// Get local graph.
75
const
auto
model = rcp(
new
GraphModel<Adapter>
(adapter, env, comm, graphFlags));
76
const
size_t
nVtx = model->getLocalNumVertices();
77
ArrayView<const gno_t> edgeIds;
78
ArrayView<const offset_t> offsets;
79
ArrayView<StridedData<lno_t, scalar_t> > wgts;
80
model->getEdgeList(edgeIds, offsets, wgts);
81
82
83
// Store degrees together with index so we can sort.
84
Teuchos::Array<std::pair<lno_t, offset_t> > degrees(nVtx);
85
for
(
lno_t
i=0; i<(
lno_t
)nVtx; i++){
86
degrees[i].first = i;
87
degrees[i].second = offsets[i+1] - offsets[i];
88
}
89
90
// Sort degrees.
91
SortPairs<lno_t,offset_t>
zort;
92
bool
inc =
true
;
// TODO: Add user parameter
93
zort.
sort
(degrees, inc);
94
95
// Copy permuted indices to perm.
96
for
(
lno_t
i=0; i<(
lno_t
)nVtx; i++){
97
perm[i] = degrees[i].first;
98
}
99
100
solution->setHavePerm(
true
);
101
return
ierr;
102
}
103
104
};
105
}
106
#endif
Zoltan2_Algorithm.hpp
Zoltan2_GraphModel.hpp
Defines the GraphModel interface.
Zoltan2_OrderingSolution.hpp
Defines the OrderingSolution class.
Zoltan2_Sort.hpp
Sort vector of pairs (key, value) by value.
HELLO
#define HELLO
Definition
Zoltan2_Standards.hpp:96
Zoltan2::AlgSortedDegree::scalar_t
Adapter::scalar_t scalar_t
Definition
Zoltan2_AlgSortedDegree.hpp:43
Zoltan2::AlgSortedDegree::AlgSortedDegree
AlgSortedDegree(const RCP< const typename Adapter::base_adapter_t > &adapter__, const RCP< Teuchos::ParameterList > &pl__, const RCP< const Teuchos::Comm< int > > &comm__, RCP< const Environment > &env__, const modelFlag_t &graphFlags__)
Definition
Zoltan2_AlgSortedDegree.hpp:45
Zoltan2::AlgSortedDegree::globalOrder
int globalOrder(const RCP< GlobalOrderingSolution< gno_t > > &)
Ordering method.
Definition
Zoltan2_AlgSortedDegree.hpp:55
Zoltan2::AlgSortedDegree::offset_t
Adapter::offset_t offset_t
Definition
Zoltan2_AlgSortedDegree.hpp:42
Zoltan2::AlgSortedDegree::lno_t
Adapter::lno_t lno_t
Definition
Zoltan2_AlgSortedDegree.hpp:40
Zoltan2::AlgSortedDegree::gno_t
Adapter::gno_t gno_t
Definition
Zoltan2_AlgSortedDegree.hpp:41
Zoltan2::AlgSortedDegree::localOrder
int localOrder(const RCP< LocalOrderingSolution< lno_t > > &solution)
Ordering method.
Definition
Zoltan2_AlgSortedDegree.hpp:61
Zoltan2::Algorithm
Algorithm defines the base class for all algorithms.
Definition
Zoltan2_Algorithm.hpp:42
Zoltan2::GlobalOrderingSolution
Definition
Zoltan2_OrderingSolution.hpp:358
Zoltan2::GraphModel
GraphModel defines the interface required for graph models.
Definition
Zoltan2_GraphModel.hpp:45
Zoltan2::LocalOrderingSolution
Definition
Zoltan2_OrderingSolution.hpp:351
Zoltan2::SortPairs
Definition
Zoltan2_Sort.hpp:46
Zoltan2::SortPairs::sort
void sort(Teuchos::Array< std::pair< key_t, value_t > > &listofPairs, bool inc=true)
Definition
Zoltan2_Sort.hpp:53
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:47
Zoltan2::modelFlag_t
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
Definition
Zoltan2_Model.hpp:57
core
src
algorithms
order
Zoltan2_AlgSortedDegree.hpp
Generated by
1.17.0