Add .clang-format and apply it
This commit is contained in:
@@ -13,8 +13,10 @@ using Edge = std::pair<Node, Node>;
|
||||
using Nodes = std::set<Node>;
|
||||
using Edges = std::map<Edge, Weight>;
|
||||
|
||||
struct Graph {
|
||||
void add_edge(std::string const &s) {
|
||||
struct Graph
|
||||
{
|
||||
void add_edge(std::string const& s)
|
||||
{
|
||||
static const std::regex re("(.+) to (.+) = (\\d+)");
|
||||
std::smatch m;
|
||||
if (!std::regex_search(s, m, re)) {
|
||||
@@ -35,7 +37,8 @@ struct Graph {
|
||||
std::cout << n1 << " <-> " << n2 << " weight: " << w << "\n";
|
||||
}
|
||||
|
||||
Weight solve_tsp() const {
|
||||
Weight solve_tsp() const
|
||||
{
|
||||
Weight min_weight = ~0U;
|
||||
visit_all_perms([&min_weight](Weight w) {
|
||||
if (w < min_weight) {
|
||||
@@ -46,7 +49,8 @@ struct Graph {
|
||||
return min_weight;
|
||||
}
|
||||
|
||||
Weight solve_max_tsp() const {
|
||||
Weight solve_max_tsp() const
|
||||
{
|
||||
Weight max_weight = 0;
|
||||
visit_all_perms([&max_weight](Weight w) {
|
||||
if (w > max_weight) {
|
||||
@@ -58,7 +62,9 @@ struct Graph {
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Fn> void visit_all_perms(Fn fn) const {
|
||||
template<typename Fn>
|
||||
void visit_all_perms(Fn fn) const
|
||||
{
|
||||
std::vector<Node> nodes(nodes_.begin(), nodes_.end());
|
||||
std::sort(nodes.begin(), nodes.end());
|
||||
do {
|
||||
@@ -80,7 +86,8 @@ private:
|
||||
Edges weights_;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Graph g;
|
||||
|
||||
// Parse the input
|
||||
|
Reference in New Issue
Block a user