Skip to content

Commit 4ff0b14

Browse files
authored
YT-CPPGL-68: Implement missing vertex view getters
- Extended the graph class with missing vertex collection getters: - Descriptor getters: neighbors, predecessors, successors - ID getters: neighbor_ids, predecessor_ids, successor_ids - Fixed the incident_edges logic error: - Previously the function always called out_edges, which is correct for undirected graphs but not for directed graphs - Extended the internal implementation classes with specific incident edges getters - Aligned the graph class methods to use the proper underlying implementation type's methods - Changed the are_incident method names for vertex pairs and edge pairs to use the proper term (are_adjacent) - Cleaned up the layout of methods in the graph class and the implementation classes - Cleaned up the gl module tests
1 parent 16e51d6 commit 4ff0b14

30 files changed

Lines changed: 2357 additions & 1724 deletions

benchmarks/suites/is_bipartite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <gl/algorithm.hpp>
55
#include <gl/graph.hpp>
6-
#include <gl/topologies.hpp>
6+
#include <gl/topology.hpp>
77

88
#include <benchmark/benchmark.h>
99

include/gl/algorithm/spanning_tree/prim_mst.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template <traits::c_undirected_graph G>
5151
if (root_id == invalid_id)
5252
root_id = initial_id;
5353

54-
for (const auto& edge : graph.incident_edges(root_id))
54+
for (const auto& edge : graph.out_edges(root_id))
5555
edge_queue.emplace(edge);
5656

5757
// mark the root vertex as visited

include/gl/algorithm/templates/bfs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool bfs(
5555
if (not visit(node.vertex_id, node.pred_id))
5656
return false;
5757

58-
for (const auto& edge : graph.incident_edges(node.vertex_id)) {
58+
for (const auto& edge : graph.out_edges(node.vertex_id)) {
5959
const auto target_vertex_id = edge.other(node.vertex_id);
6060
const auto enqueue = enqueue_vertex_pred(target_vertex_id, edge);
6161
if (enqueue == decision::abort)

include/gl/algorithm/templates/dfs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool dfs(
5555
if (not visit(node.vertex_id, node.pred_id))
5656
return false;
5757

58-
for (const auto& edge : graph.incident_edges(node.vertex_id)) {
58+
for (const auto& edge : graph.out_edges(node.vertex_id)) {
5959
const auto target_vertex_id = edge.other(node.vertex_id);
6060
if (enqueue_vertex_pred(target_vertex_id, edge))
6161
s.emplace(target_vertex_id, node.vertex_id);
@@ -96,7 +96,7 @@ void r_dfs(
9696
visit(vertex_id, pred_id);
9797

9898
// recursively search vertices adjacent to the current vertex
99-
for (const auto& edge : graph.incident_edges(vertex_id)) {
99+
for (const auto& edge : graph.out_edges(vertex_id)) {
100100
const auto target_vertex_id = edge.other(vertex_id);
101101
if (enqueue_vertex_pred(target_vertex_id, edge))
102102
r_dfs(

include/gl/algorithm/templates/pfs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool pfs(
5959
if (not visit(node.vertex_id, node.pred_id))
6060
return false;
6161

62-
for (const auto& edge : graph.incident_edges(node.vertex_id)) {
62+
for (const auto& edge : graph.out_edges(node.vertex_id)) {
6363
const auto target_vertex_id = edge.other(node.vertex_id);
6464
const auto enqueue = enqueue_vertex_pred(target_vertex_id, edge);
6565
if (enqueue == decision::abort)

0 commit comments

Comments
 (0)