Skip to content

Commit d74cdc5

Browse files
committed
in_edge
1 parent d7cba6f commit d74cdc5

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

include/osp/graph_algorithms/directed_graph_edge_view.hpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ class in_edge_view {
266266
private:
267267
static_assert(is_directed_graph_v<Graph_t>, "Graph_t must satisfy the directed_graph concept");
268268

269-
const Graph_t &graph;
270-
vertex_idx_t<Graph_t> target_vertex;
269+
const Graph_t &graph_;
270+
vertex_idx_t<Graph_t> targetVertex_;
271271

272272
template<typename parent_iterator_t>
273-
class in_edge_iterator {
273+
class InEdgeIterator {
274274
public:
275275
using iterator_category = typename std::iterator_traits<parent_iterator_t>::iterator_category;
276276
using difference_type = std::ptrdiff_t;
@@ -284,60 +284,59 @@ class in_edge_view {
284284
};
285285

286286
private:
287-
vertex_idx_t<Graph_t> target_vertex;
288-
parent_iterator_t current_parent_it;
287+
vertex_idx_t<Graph_t> targetVertex_;
288+
parent_iterator_t currentParentIt_;
289289

290290
public:
291-
in_edge_iterator() = default;
292-
in_edge_iterator(vertex_idx_t<Graph_t> v, parent_iterator_t it) : target_vertex(v), current_parent_it(it) {}
291+
InEdgeIterator() = default;
292+
InEdgeIterator(vertex_idx_t<Graph_t> v, parent_iterator_t it) : targetVertex_(v), currentParentIt_(it) {}
293293

294-
[[nodiscard]] value_type operator*() const { return {*current_parent_it, target_vertex}; }
294+
[[nodiscard]] value_type operator*() const { return {*currentParentIt_, targetVertex_}; }
295295
[[nodiscard]] arrow_proxy operator->() const { return {operator*()}; }
296296

297-
in_edge_iterator &operator++() {
298-
++current_parent_it;
297+
InEdgeIterator &operator++() {
298+
++currentParentIt_;
299299
return *this;
300300
}
301301

302-
in_edge_iterator operator++(int) {
303-
in_edge_iterator temp = *this;
302+
InEdgeIterator operator++(int) {
303+
InEdgeIterator temp = *this;
304304
++(*this);
305305
return temp;
306306
}
307307

308-
in_edge_iterator &operator--() {
309-
--current_parent_it;
308+
InEdgeIterator &operator--() {
309+
--currentParentIt_;
310310
return *this;
311311
}
312312

313-
in_edge_iterator operator--(int) {
314-
in_edge_iterator temp = *this;
313+
InEdgeIterator operator--(int) {
314+
InEdgeIterator temp = *this;
315315
--(*this);
316316
return temp;
317317
}
318318

319-
[[nodiscard]] bool operator==(const in_edge_iterator &other) const noexcept {
320-
return current_parent_it == other.current_parent_it;
319+
[[nodiscard]] bool operator==(const InEdgeIterator &other) const noexcept {
320+
return currentParentIt_ == other.currentParentIt_;
321321
}
322322

323-
[[nodiscard]] bool operator!=(const in_edge_iterator &other) const noexcept { return !(*this == other); }
323+
[[nodiscard]] bool operator!=(const InEdgeIterator &other) const noexcept { return !(*this == other); }
324324
};
325325

326326
public:
327-
using iterator =
328-
in_edge_iterator<decltype(std::declval<Graph_t>().parents(std::declval<vertex_idx_t<Graph_t>>()).begin())>;
329-
using const_iterator = iterator;
327+
using iterator = InEdgeIterator<decltype(std::declval<Graph_t>().parents(std::declval<vertex_idx_t<Graph_t>>()).begin())>;
328+
using constIterator = iterator;
330329

331-
in_edge_view(const Graph_t &graph_, vertex_idx_t<Graph_t> v) : graph(graph_), target_vertex(v) {}
330+
in_edge_view(const Graph_t &graph, vertex_idx_t<Graph_t> v) : graph_(graph), targetVertex_(v) {}
332331

333-
[[nodiscard]] auto begin() const { return iterator(target_vertex, graph.parents(target_vertex).begin()); }
332+
[[nodiscard]] auto begin() const { return iterator(targetVertex_, graph_.parents(targetVertex_).begin()); }
334333
[[nodiscard]] auto cbegin() const { return begin(); }
335334

336-
[[nodiscard]] auto end() const { return iterator(target_vertex, graph.parents(target_vertex).end()); }
335+
[[nodiscard]] auto end() const { return iterator(targetVertex_, graph_.parents(targetVertex_).end()); }
337336
[[nodiscard]] auto cend() const { return end(); }
338337

339-
[[nodiscard]] auto size() const { return graph.in_degree(target_vertex); }
340-
[[nodiscard]] bool empty() const { return graph.in_degree(target_vertex) == 0; }
338+
[[nodiscard]] auto size() const { return graph_.in_degree(targetVertex_); }
339+
[[nodiscard]] bool empty() const { return graph_.in_degree(targetVertex_) == 0; }
341340
};
342341

343342
} // namespace osp

0 commit comments

Comments
 (0)