53 #ifndef _ZOLTAN2_COMPONENTMETRICS_HPP_ 54 #define _ZOLTAN2_COMPONENTMETRICS_HPP_ 58 #include <Teuchos_Comm.hpp> 64 template <
typename Adapter>
68 typedef typename Adapter::lno_t
lno_t;
69 typedef typename Adapter::gno_t
gno_t;
73 const Teuchos::Comm<int> &comm);
75 #ifdef HAVE_ZOLTAN2_MPI 93 size_t maxComponentSize;
94 size_t minComponentSize;
95 double avgComponentSize;
97 inline void markAndEnqueue(std::queue<gno_t> &q,
bool *mark,
98 size_t &nUnmarkedVtx,
size_t &cSize, gno_t vtx) {
112 template <
typename Adapter>
114 const Adapter &ia,
const Teuchos::Comm<int> &comm) :
115 nComponent(0), maxComponentSize(0), minComponentSize(0),
119 std::bitset<NUM_MODEL_FLAGS> graphFlags;
124 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = rcp(&comm,
false);
125 Teuchos::RCP<const Zoltan2::Environment> env =
129 Teuchos::RCP<const base_adapter_t> ria = rcp(&ia,
false);
134 ArrayView<const gno_t> adj;
135 ArrayView<const lno_t> offset;
136 ArrayView<StridedData<lno_t, scalar_t> > wgts;
141 size_t nUnmarkedVtx = nVtx;
142 bool *mark =
new bool[nUnmarkedVtx];
143 for (
size_t i = 0; i < nUnmarkedVtx; i++) mark[i] =
false;
149 while (nUnmarkedVtx > 0) {
156 while (mark[startVtx]) startVtx++;
157 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, startVtx);
160 gno_t vtx = q.front();
164 for (
lno_t j = offset[vtx]; j < offset[vtx+1]; j++) {
166 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, adj[j]);
172 if (nComponent == 1) {
173 maxComponentSize = cSize;
174 minComponentSize = cSize;
177 if (cSize > maxComponentSize) maxComponentSize = cSize;
178 if (cSize < minComponentSize) minComponentSize = cSize;
183 if (nComponent) avgComponentSize = double(nVtx) / double(nComponent);
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Adapter::scalar_t scalar_t
size_t getLocalNumVertices() const
Returns the number vertices on this process.
~perProcessorComponentMetrics()
double getAvgComponentSize()
size_t getEdgeList(ArrayView< const gno_t > &edgeIds, ArrayView< const lno_t > &offsets, ArrayView< input_t > &wgts) const
Sets pointers to this process' edge (neighbor) global Ids, including off-process edges.
size_t getMaxComponentSize()
algorithm requires no self edges
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
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)