17 #ifndef _ZOLTAN2_COMPONENTMETRICS_HPP_
18 #define _ZOLTAN2_COMPONENTMETRICS_HPP_
22 #include <Teuchos_Comm.hpp>
28 template <
typename Adapter>
38 const Teuchos::Comm<int> &comm);
40 #ifdef HAVE_ZOLTAN2_MPI
45 Teuchos::MpiComm<int>(Teuchos::opaqueWrapper(mpicomm)))
58 size_t maxComponentSize;
59 size_t minComponentSize;
60 double avgComponentSize;
62 inline void markAndEnqueue(std::queue<gno_t> &q,
bool *mark,
63 size_t &nUnmarkedVtx,
size_t &cSize,
gno_t vtx) {
77 template <
typename Adapter>
79 const Adapter &ia,
const Teuchos::Comm<int> &comm) :
80 nComponent(0), maxComponentSize(0), minComponentSize(0),
84 std::bitset<NUM_MODEL_FLAGS> graphFlags;
89 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = rcp(&comm,
false);
90 Teuchos::RCP<const Zoltan2::Environment> env =
94 Teuchos::RCP<const base_adapter_t> ria = rcp(&ia,
false);
99 ArrayView<const gno_t> adj;
100 ArrayView<const offset_t> offset;
101 ArrayView<StridedData<lno_t, scalar_t> > wgts;
106 size_t nUnmarkedVtx = nVtx;
107 bool *mark =
new bool[nUnmarkedVtx];
108 for (
size_t i = 0; i < nUnmarkedVtx; i++) mark[i] =
false;
114 while (nUnmarkedVtx > 0) {
121 while (mark[startVtx]) startVtx++;
122 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, startVtx);
125 gno_t vtx = q.front();
129 for (
offset_t j = offset[vtx]; j < offset[vtx+1]; j++) {
131 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, adj[j]);
137 if (nComponent == 1) {
138 maxComponentSize = cSize;
139 minComponentSize = cSize;
142 if (cSize > maxComponentSize) maxComponentSize = cSize;
143 if (cSize < minComponentSize) minComponentSize = cSize;
148 if (nComponent) avgComponentSize = double(nVtx) / double(nComponent);
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Adapter::offset_t offset_t
Adapter::scalar_t scalar_t
map_t::global_ordinal_type gno_t
~perProcessorComponentMetrics()
double getAvgComponentSize()
size_t getMaxComponentSize()
algorithm requires no self edges
size_t getEdgeList(ArrayView< const gno_t > &edgeIds, ArrayView< const offset_t > &offsets, ArrayView< input_t > &wgts) const
Sets pointers to this process' edge (neighbor) global Ids, including off-process edges.
map_t::local_ordinal_type lno_t
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
size_t getLocalNumVertices() const
Returns the number vertices on this process.
size_t getNumComponents()
GraphModel defines the interface required for graph models.
Gathering definitions used in software development.
size_t getMinComponentSize()
Defines the GraphModel interface.
model represents graph within only one rank
perProcessorComponentMetrics(const Adapter &ia, const Teuchos::Comm< int > &comm)