-
Notifications
You must be signed in to change notification settings - Fork 17
Feature/edge range #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2357b28 to
8723531
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new EdgeRange class that provides unified iteration over graph edges regardless of their internal representation (edge list or CSR). The implementation includes both the core functionality and comprehensive test coverage.
Key changes:
- Added
EdgeRangeclass supporting iteration over both edge list and CSR graph representations - Implemented forward iterator pattern with proper operator overloading
- Created comprehensive test suite covering both sparse and dense graphs in both representations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| kagen/edge_range.h | Declares the EdgeRange class and its iterator interface for unified edge iteration |
| kagen/edge_range.cpp | Implements iteration logic for both edge list and CSR representations |
| tests/edge_range.cpp | Tests edge iteration across multiple graph types and representations |
| tests/CMakeLists.txt | Adds test configuration for the new edge range test suite |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| explicit EdgeRange(const Edgelist& edgelist) noexcept; | ||
| EdgeRange(const XadjArray& xadj, const AdjncyArray& adjncy, VertexRange vertex_range) noexcept; | ||
| EdgeRange(const Graph& graph)noexcept; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space between closing parenthesis and noexcept keyword. Should be EdgeRange(const Graph& graph) noexcept; for consistency with other declarations in the file.
| EdgeRange(const Graph& graph)noexcept; | |
| EdgeRange(const Graph& graph) noexcept; |
tests/edge_range.cpp
Outdated
| void check_edge_range(const Graph& graph) { | ||
| Edgelist edgelist = graph.edges; | ||
| if (graph.representation == GraphRepresentation::CSR) { | ||
| edgelist = BuildEdgeListFromCSR(graph.vertex_range, graph.xadj, graph.adjncy); | ||
| } | ||
| EdgeRange edge_range(graph); | ||
|
|
||
| { | ||
| std::size_t expected_index = 0; | ||
| for (auto it = edge_range.begin(); it != edge_range.end(); ++it) { | ||
| auto edge = *it; | ||
| EXPECT_EQ(it.edge_index(), expected_index); | ||
| EXPECT_EQ(*it, edge); | ||
| ++expected_index; | ||
| } | ||
| } | ||
|
|
||
| { | ||
| EXPECT_EQ(edge_range.size(), edgelist.size()); | ||
| for (std::size_t i = 0; auto elem: edge_range) { | ||
| EXPECT_EQ(elem, edgelist[i]); | ||
| ++i; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider putting this directly in the assertion via matchers, this makes the test output more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you show an example?
|
@niklas-uhl I've opened a new pull request, #76, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@niklas-uhl I've opened a new pull request, #77, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…d tests (#76) * Initial plan * Refactor edge_range test to use GoogleTest matchers Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Use matchers for edge index verification as well Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Remove check_edge_range helper and inline logic into tests Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Remove unnecessary CSR check from edgelist tests Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Convert tests to parameterized tests by generator type and remove always-true conditionals Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Use custom matcher for edge index check without allocating vector Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Revert custom matcher, use explicit loop for edge index check Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> * Use Pointwise matcher with EdgeIndexMatches for edge index verification Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: niklas-uhl <23433189+niklas-uhl@users.noreply.github.com> Co-authored-by: Tim Niklas Uhl <uhl@kit.edu>
No description provided.