Skip to content

Commit 4ce1047

Browse files
committed
build fix
1 parent 3009f8e commit 4ce1047

5 files changed

Lines changed: 191 additions & 64 deletions

File tree

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ AlignTrailingComments:
7373
AllowAllArgumentsOnNextLine: true
7474
AllowAllParametersOfDeclarationOnNextLine: true
7575
AllowBreakBeforeNoexceptSpecifier: Never
76-
AllowShortBlocksOnASingleLine: Always
76+
AllowShortBlocksOnASingleLine: Empty
7777
AllowShortCaseExpressionOnASingleLine: true
7878
AllowShortCaseLabelsOnASingleLine: false
7979
AllowShortCompoundRequirementOnASingleLine: true

include/osp/auxiliary/permute.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818

1919
#pragma once
2020

21+
#include <cassert>
2122
#include <type_traits>
2223
#include <utility>
2324
#include <vector>
@@ -33,9 +34,15 @@ void permute_inplace(std::vector<T> &vec, std::vector<Ind> &perm) {
3334
assert([&]() -> bool {
3435
std::vector<bool> found(perm.size(), false);
3536
for (const Ind &val : perm) {
36-
if (val < 0) { return false; }
37-
if (val >= perm.size()) { return false; }
38-
if (found[val]) { return false; }
37+
if (val < 0) {
38+
return false;
39+
}
40+
if (val >= perm.size()) {
41+
return false;
42+
}
43+
if (found[val]) {
44+
return false;
45+
}
3946
found[val] = true;
4047
}
4148
return true;
@@ -59,9 +66,15 @@ void inverse_permute_inplace(std::vector<T> &vec, std::vector<Ind> &perm) {
5966
assert([&]() -> bool {
6067
std::vector<bool> found(perm.size(), false);
6168
for (const Ind &val : perm) {
62-
if (val < 0) { return false; }
63-
if (val >= perm.size()) { return false; }
64-
if (found[val]) { return false; }
69+
if (val < 0) {
70+
return false;
71+
}
72+
if (val >= perm.size()) {
73+
return false;
74+
}
75+
if (found[val]) {
76+
return false;
77+
}
6578
found[val] = true;
6679
}
6780
return true;

include/osp/graph_algorithms/directed_graph_edge_desc_util.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
#include <unordered_set>
2323
#include <vector>
2424

25-
#include "osp/concepts/directed_graph_concept.hpp"
25+
#include "osp/concepts/directed_graph_edge_desc_concept.hpp"
2626

2727
namespace osp {
2828

@@ -33,7 +33,9 @@ std::pair<edge_desc_t<Graph_t>, bool> edge_desc(const vertex_idx_t<Graph_t> &src
3333
static_assert(is_directed_graph_edge_desc_v<Graph_t>, "Graph_t must satisfy the directed_graph edge desc concept");
3434

3535
for (const auto &edge : out_edges(src, graph)) {
36-
if (target(edge, graph) == dest) { return {edge, true}; }
36+
if (target(edge, graph) == dest) {
37+
return {edge, true};
38+
}
3739
}
3840
return {edge_desc_t<Graph_t>(), false};
3941
}
@@ -48,7 +50,9 @@ std::unordered_set<edge_desc_t<Graph_t>> long_edges_in_triangles(const Graph_t &
4850
for (const auto &vertex : graph.vertices()) {
4951
std::unordered_set<vertex_idx_t<Graph_t>> children_set;
5052

51-
for (const auto &v : graph.children(vertex)) { children_set.emplace(v); }
53+
for (const auto &v : graph.children(vertex)) {
54+
children_set.emplace(v);
55+
}
5256

5357
for (const auto &edge : out_edges(vertex, graph)) {
5458
const auto &child = target(edge, graph);

include/osp/graph_algorithms/directed_graph_util.hpp

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818

1919
#pragma once
2020

21+
#include <limits>
2122
#include <queue>
2223
#include <unordered_set>
2324
#include <vector>
@@ -49,7 +50,9 @@ template <typename Graph_t>
4950
bool edge(const vertex_idx_t<Graph_t> &src, const vertex_idx_t<Graph_t> &dest, const Graph_t &graph) {
5051
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
5152
for (const auto &child : graph.children(src)) {
52-
if (child == dest) { return true; }
53+
if (child == dest) {
54+
return true;
55+
}
5356
}
5457
return false;
5558
}
@@ -108,7 +111,9 @@ struct vertex_cond_iterator {
108111
vertex_cond_iterator(const Graph_t &graph_, const iterator_t &start) : graph(graph_), current_vertex(start) {
109112
while (current_vertex != graph.vertices().end()) {
110113
// if (cond.eval(graph, *current_vertex)) {
111-
if (cond(graph, *current_vertex)) { break; }
114+
if (cond(graph, *current_vertex)) {
115+
break;
116+
}
112117
current_vertex++;
113118
}
114119
}
@@ -120,7 +125,9 @@ struct vertex_cond_iterator {
120125
current_vertex++;
121126

122127
while (current_vertex != graph.vertices().end()) {
123-
if (cond(graph, *current_vertex)) { break; }
128+
if (cond(graph, *current_vertex)) {
129+
break;
130+
}
124131
current_vertex++;
125132
}
126133

@@ -208,7 +215,9 @@ template <typename Graph_t>
208215
std::vector<vertex_idx_t<Graph_t>> source_vertices(const Graph_t &graph) {
209216
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
210217
std::vector<vertex_idx_t<Graph_t>> vec;
211-
for (const auto &source : source_vertices_view(graph)) { vec.push_back(source); }
218+
for (const auto &source : source_vertices_view(graph)) {
219+
vec.push_back(source);
220+
}
212221
return vec;
213222
}
214223

@@ -224,7 +233,9 @@ std::vector<vertex_idx_t<Graph_t>> sink_vertices(const Graph_t &graph) {
224233
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
225234
std::vector<vertex_idx_t<Graph_t>> vec;
226235

227-
for (const auto &sink : sink_vertices_view(graph)) { vec.push_back(sink); }
236+
for (const auto &sink : sink_vertices_view(graph)) {
237+
vec.push_back(sink);
238+
}
228239
return vec;
229240
}
230241

@@ -257,7 +268,9 @@ struct traversal_iterator {
257268

258269
traversal_iterator(const Graph_t &graph_, const vertex_idx_t<Graph_t> &start)
259270
: graph(graph_), adj_iter(graph_), current_vertex(start) {
260-
if (graph.num_vertices() == start) { return; }
271+
if (graph.num_vertices() == start) {
272+
return;
273+
}
261274

262275
visited.insert(start);
263276

@@ -435,7 +448,9 @@ template <typename Graph_t>
435448
std::vector<vertex_idx_t<Graph_t>> successors(const vertex_idx_t<Graph_t> &v, const Graph_t &graph) {
436449
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
437450
std::vector<vertex_idx_t<Graph_t>> vec;
438-
for (const auto &suc : bfs_view(graph, v)) { vec.push_back(suc); }
451+
for (const auto &suc : bfs_view(graph, v)) {
452+
vec.push_back(suc);
453+
}
439454
return vec;
440455
}
441456

@@ -451,7 +466,9 @@ template <typename Graph_t>
451466
std::vector<vertex_idx_t<Graph_t>> ancestors(const vertex_idx_t<Graph_t> &v, const Graph_t &graph) {
452467
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
453468
std::vector<vertex_idx_t<Graph_t>> vec;
454-
for (const auto &anc : bfs_reverse_view(graph, v)) { vec.push_back(anc); }
469+
for (const auto &anc : bfs_reverse_view(graph, v)) {
470+
vec.push_back(anc);
471+
}
455472
return vec;
456473
}
457474

@@ -461,14 +478,18 @@ bool is_acyclic(const Graph_t &graph) {
461478

462479
using VertexType = vertex_idx_t<Graph_t>;
463480

464-
if (graph.num_vertices() < 2) { return true; }
481+
if (graph.num_vertices() < 2) {
482+
return true;
483+
}
465484

466485
std::vector<VertexType> predecessors_count(graph.num_vertices(), 0);
467486

468487
std::queue<VertexType> next;
469488

470489
// Find source nodes
471-
for (const VertexType &v : source_vertices_view(graph)) { next.push(v); }
490+
for (const VertexType &v : source_vertices_view(graph)) {
491+
next.push(v);
492+
}
472493

473494
VertexType node_count = 0;
474495
while (!next.empty()) {
@@ -478,7 +499,9 @@ bool is_acyclic(const Graph_t &graph) {
478499

479500
for (const VertexType &current : graph.children(node)) {
480501
++predecessors_count[current];
481-
if (predecessors_count[current] == graph.in_degree(current)) { next.push(current); }
502+
if (predecessors_count[current] == graph.in_degree(current)) {
503+
next.push(current);
504+
}
482505
}
483506
}
484507

@@ -491,7 +514,9 @@ bool is_connected(const Graph_t &graph) {
491514

492515
using VertexType = vertex_idx_t<Graph_t>;
493516

494-
if (graph.num_vertices() < 2) { return true; }
517+
if (graph.num_vertices() < 2) {
518+
return true;
519+
}
495520

496521
std::unordered_set<VertexType> visited;
497522

@@ -522,11 +547,15 @@ std::size_t num_common_parents(const Graph_t &graph, vertex_idx_t<Graph_t> v1, v
522547

523548
std::unordered_set<vertex_idx_t<Graph_t>> parents;
524549
parents.reserve(graph.in_degree(v1));
525-
for (const auto &par : graph.parents(v1)) { parents.emplace(par); }
550+
for (const auto &par : graph.parents(v1)) {
551+
parents.emplace(par);
552+
}
526553

527554
std::size_t num = 0;
528555
for (const auto &par : graph.parents(v2)) {
529-
if (parents.find(par) != parents.end()) { ++num; }
556+
if (parents.find(par) != parents.end()) {
557+
++num;
558+
}
530559
}
531560

532561
return num;
@@ -538,11 +567,15 @@ std::size_t num_common_children(const Graph_t &graph, vertex_idx_t<Graph_t> v1,
538567

539568
std::unordered_set<vertex_idx_t<Graph_t>> childrn;
540569
childrn.reserve(graph.out_degree(v1));
541-
for (const auto &chld : graph.children(v1)) { childrn.emplace(chld); }
570+
for (const auto &chld : graph.children(v1)) {
571+
childrn.emplace(chld);
572+
}
542573

543574
std::size_t num = 0;
544575
for (const auto &chld : graph.children(v2)) {
545-
if (childrn.find(chld) != childrn.end()) { ++num; }
576+
if (childrn.find(chld) != childrn.end()) {
577+
++num;
578+
}
546579
}
547580

548581
return num;

0 commit comments

Comments
 (0)