53#ifndef _ZOLTAN2_COMPONENTMETRICS_HPP_
54#define _ZOLTAN2_COMPONENTMETRICS_HPP_
58#include <Teuchos_Comm.hpp>
64template <
typename Adapter>
68 typedef typename Adapter::lno_t
lno_t;
69 typedef typename Adapter::gno_t
gno_t;
74 const Teuchos::Comm<int> &comm);
76#ifdef HAVE_ZOLTAN2_MPI
94 size_t maxComponentSize;
95 size_t minComponentSize;
96 double avgComponentSize;
98 inline void markAndEnqueue(std::queue<gno_t> &q,
bool *mark,
99 size_t &nUnmarkedVtx,
size_t &cSize,
gno_t vtx) {
113template <
typename Adapter>
115 const Adapter &ia,
const Teuchos::Comm<int> &comm) :
116 nComponent(0), maxComponentSize(0), minComponentSize(0),
120 std::bitset<NUM_MODEL_FLAGS> graphFlags;
125 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = rcp(&comm,
false);
126 Teuchos::RCP<const Zoltan2::Environment> env =
129 typedef typename Adapter::base_adapter_t base_adapter_t;
130 Teuchos::RCP<const base_adapter_t> ria = rcp(&ia,
false);
135 ArrayView<const gno_t> adj;
136 ArrayView<const offset_t> offset;
137 ArrayView<StridedData<lno_t, scalar_t> > wgts;
142 size_t nUnmarkedVtx = nVtx;
143 bool *mark =
new bool[nUnmarkedVtx];
144 for (
size_t i = 0; i < nUnmarkedVtx; i++) mark[i] =
false;
150 while (nUnmarkedVtx > 0) {
157 while (mark[startVtx]) startVtx++;
158 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, startVtx);
161 gno_t vtx = q.front();
165 for (
offset_t j = offset[vtx]; j < offset[vtx+1]; j++) {
167 markAndEnqueue(q, mark, nUnmarkedVtx, cSize, adj[j]);
173 if (nComponent == 1) {
174 maxComponentSize = cSize;
175 minComponentSize = cSize;
178 if (cSize > maxComponentSize) maxComponentSize = cSize;
179 if (cSize < minComponentSize) minComponentSize = cSize;
184 if (nComponent) avgComponentSize = double(nVtx) / double(nComponent);
Defines the GraphModel interface.
Gathering definitions used in software development.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
GraphModel defines the interface required for graph models.
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.
size_t getLocalNumVertices() const
Returns the number vertices on this process.
size_t getMinComponentSize()
size_t getMaxComponentSize()
~perProcessorComponentMetrics()
double getAvgComponentSize()
perProcessorComponentMetrics(const Adapter &ia, const Teuchos::Comm< int > &comm)
Adapter::offset_t offset_t
size_t getNumComponents()
Adapter::scalar_t scalar_t
map_t::global_ordinal_type gno_t
Created by mbenlioglu on Aug 31, 2020.
@ REMOVE_SELF_EDGES
algorithm requires no self edges
@ BUILD_LOCAL_GRAPH
model represents graph within only one rank