Zoltan2
Loading...
Searching...
No Matches
Zoltan2_GraphMetrics.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
13#ifndef ZOLTAN2_GRAPHCMETRICS_HPP
14#define ZOLTAN2_GRAPHCMETRICS_HPP
15
19
20#define GRAPH_METRICS_TYPE_NAME "GraphMetrics"
21
22namespace Zoltan2{
23
25template <typename scalar_t>
26 class GraphMetrics : public BaseClassMetrics<scalar_t> {
27
28public:
30GraphMetrics(std::string mname) : BaseClassMetrics<scalar_t>(static_metricNames_.size(), mname) {}
31
34
36virtual const std::string & getMetricType() const { return GraphMetrics<scalar_t>::static_metricTypeName_; }
37
39static void printHeader(std::ostream &os);
40
42virtual void printLine(std::ostream &os) const;
43
45void setGlobalSum(scalar_t x) { this->setMetricValue("global sum", x);}
46
48void setGlobalMax(scalar_t x) { this->setValue("global maximum", x);}
49
51scalar_t getGlobalSum() const { return this->getMetricValue("global sum");}
52
54scalar_t getGlobalMax() const { return this->getMetricValue("global maximum");}
55
57virtual const std::vector<std::string> & getMetrics() const { return GraphMetrics<scalar_t>::static_metricNames_; }
58
60static std::vector<std::string> static_metricNames_;
61
63static std::string static_metricTypeName_;
64}; // end class
65
67template <typename scalar_t>
69
71template <typename scalar_t>
72std::vector<std::string> GraphMetrics<scalar_t>::static_metricNames_ = {
73 "global sum",
74 "global maximum"
75};
76
77template <typename scalar_t>
79{
80 os << std::setw(20) << " ";
81 os << std::setw(12) << "total" << std::setw(12) << "max";
82 os << std::endl;
83}
84
85template <typename scalar_t>
86 void GraphMetrics<scalar_t>::printLine(std::ostream &os) const
87{
88 std::string label( this->getName() );
89
90 os << std::setw(20) << label;
91 os << std::setw(12) << std::setprecision(4) << this->getMetricValue("global sum");
92 os << std::setw(12) << std::setprecision(4) << this->getMetricValue("global maximum");
93
94 os << std::endl;
95}
96
97} //namespace Zoltan2
98#endif
#define GRAPH_METRICS_TYPE_NAME
Defines the GraphModel interface.
void setMetricValue(const std::string &metric_name, scalar_t value) const
void setValue(int enumIndex, scalar_t value)
scalar_t getMetricValue(const std::string &metric_name) const
static void printHeader(std::ostream &os)
Print a standard header.
scalar_t getGlobalSum() const
Get the global sum of edge cuts for all parts.
static std::string static_metricTypeName_
virtual const std::string & getMetricType() const
Get the class type of the metric.
void setGlobalMax(scalar_t x)
Set the global maximum across parts.
void setGlobalSum(scalar_t x)
Set the global sum.
virtual void printLine(std::ostream &os) const
Print a standard line of data that fits under the header.
static std::vector< std::string > static_metricNames_
virtual const std::vector< std::string > & getMetrics() const
scalar_t getGlobalMax() const
Get the global maximum of edge cuts per part across all parts.
GraphMetrics(std::string mname)
Constructor.
Created by mbenlioglu on Aug 31, 2020.