Skip to content

Commit ce76231

Browse files
committed
n_vertices -> order
1 parent 6069d5c commit ce76231

19 files changed

Lines changed: 64 additions & 64 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int main() {
101101
graph.add_edge(4, 3);
102102

103103
// print the size of the graph
104-
std::cout << std::format("number of vertices: {}\n", graph.n_vertices())
104+
std::cout << std::format("number of vertices: {}\n", graph.order())
105105
<< std::format("number of edges: {}\n", graph.n_edges());
106106
}
107107
```

docs/graph.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Based on the specified traits, the `graph` class defines the following types:
123123

124124
### Size Operations
125125

126-
- **`graph.n_vertices() const noexcept`**:
126+
- **`graph.order() const noexcept`**:
127127
- *Description*: Returns the total number of vertices in the graph.
128128
- *Returned value*: $|V|$ where $V$ is the vertex set of the graph
129129
- *Return type*: `types::size_type`

include/gl/algorithm/breadth_first_search.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl::alg_return_type<ResultDiscriminator, predecessors_descriptor> breadth_firs
2424
using vertex_type = typename GraphType::vertex_type;
2525
using edge_type = typename GraphType::edge_type;
2626

27-
std::vector<bool> visited(graph.n_vertices(), false);
28-
std::vector<types::id_type> sources(graph.n_vertices());
27+
std::vector<bool> visited(graph.order(), false);
28+
std::vector<types::id_type> sources(graph.order());
2929

3030
auto pd = impl::init_return_value<ResultDiscriminator, predecessors_descriptor>(graph);
3131

include/gl/algorithm/coloring.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ template <
2323
using edge_type = typename GraphType::edge_type;
2424

2525
std::optional<bicoloring_type> coloring_opt;
26-
coloring_opt.emplace(graph.n_vertices(), bin_color_value::unset);
26+
coloring_opt.emplace(graph.order(), bin_color_value::unset);
2727
auto& coloring = coloring_opt.value();
2828

2929
for (const auto root_id : graph.vertex_ids()) {
@@ -78,7 +78,7 @@ requires(type_traits::c_binary_color_properties_type<typename GraphType::vertex_
7878
bool apply_coloring(GraphType& graph, const ColorRange& color_range) {
7979
using color_type = typename GraphType::vertex_properties_type::color_type;
8080

81-
if (std::ranges::size(color_range) != graph.n_vertices())
81+
if (std::ranges::size(color_range) != graph.order())
8282
return false;
8383

8484
auto vertices = graph.vertices(); // store the view to extend its lifetime

include/gl/algorithm/depth_first_search.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl::alg_return_type<ResultDiscriminator, predecessors_descriptor> depth_first_
2323
using vertex_type = typename GraphType::vertex_type;
2424
using edge_type = typename GraphType::edge_type;
2525

26-
std::vector<bool> visited(graph.n_vertices(), false);
27-
std::vector<types::id_type> sources(graph.n_vertices());
26+
std::vector<bool> visited(graph.order(), false);
27+
std::vector<types::id_type> sources(graph.order());
2828

2929
auto pd = impl::init_return_value<ResultDiscriminator, predecessors_descriptor>(graph);
3030

@@ -70,8 +70,8 @@ impl::alg_return_type<ResultDiscriminator, predecessors_descriptor> recursive_de
7070
using vertex_type = typename GraphType::vertex_type;
7171
using edge_type = typename GraphType::edge_type;
7272

73-
std::vector<bool> visited(graph.n_vertices(), false);
74-
std::vector<types::id_type> sources(graph.n_vertices());
73+
std::vector<bool> visited(graph.order(), false);
74+
std::vector<types::id_type> sources(graph.order());
7575

7676
auto pd = impl::init_return_value<ResultDiscriminator, predecessors_descriptor>(graph);
7777

include/gl/algorithm/dijkstra.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ template <type_traits::c_graph GraphType>
5959
[[nodiscard]] gl_attr_force_inline paths_descriptor_type<GraphType> make_paths_descriptor(
6060
const GraphType& graph
6161
) {
62-
return paths_descriptor_type<GraphType>{graph.n_vertices()};
62+
return paths_descriptor_type<GraphType>{graph.order()};
6363
}
6464

6565
template <

include/gl/algorithm/impl/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template <
1818
init_return_value(const GraphType& graph) {
1919
using return_type = alg_return_type_non_void<ResultDiscriminator, ReturnType>;
2020
if constexpr (ResultDiscriminator == algorithm::ret)
21-
return return_type(graph.n_vertices());
21+
return return_type(graph.order());
2222
else
2323
return return_type();
2424
}

include/gl/algorithm/mst.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template <type_traits::c_undirected_graph GraphType>
4747
using queue_type = std::priority_queue<edge_type, std::vector<edge_type>, edge_comparator>;
4848

4949
// prepare the necessary utility
50-
const auto n_vertices = graph.n_vertices();
50+
const auto n_vertices = graph.order();
5151
mst_descriptor<GraphType> mst(n_vertices);
5252
std::vector<bool> visited(n_vertices, false);
5353
queue_type edge_queue;
@@ -96,7 +96,7 @@ requires type_traits::c_has_numeric_limits_max<types::vertex_distance_type<Graph
9696
using distance_type = types::vertex_distance_type<GraphType>;
9797

9898
// Prepare the necessary utility
99-
const auto n_vertices = graph.n_vertices();
99+
const auto n_vertices = graph.order();
100100
mst_descriptor<GraphType> mst(n_vertices);
101101

102102
std::vector<bool> in_mst(n_vertices, false);

include/gl/algorithm/topological_sort.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ template <
2525

2626
// prepare the initial queue content (source vertices)
2727
std::vector<algorithm::vertex_info> source_vertex_list;
28-
source_vertex_list.reserve(graph.n_vertices());
28+
source_vertex_list.reserve(graph.order());
2929
for (const auto id : graph.vertex_ids())
3030
if (in_degree_map[id] == 0uz)
3131
source_vertex_list.emplace_back(id);
3232

3333
std::optional<std::vector<types::id_type>> topological_order_opt =
3434
std::vector<types::id_type>{};
3535
auto& topological_order = topological_order_opt.value();
36-
topological_order.reserve(graph.n_vertices());
36+
topological_order.reserve(graph.order());
3737

3838
impl::bfs(
3939
graph,
@@ -55,7 +55,7 @@ template <
5555
post_visit
5656
);
5757

58-
if (topological_order.size() != graph.n_vertices())
58+
if (topological_order.size() != graph.order())
5959
return std::nullopt;
6060

6161
return topological_order_opt;

include/gl/graph.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class graph final {
5959

6060
// --- general methods ---
6161

62-
[[nodiscard]] gl_attr_force_inline types::size_type n_vertices() const noexcept {
62+
[[nodiscard]] gl_attr_force_inline types::size_type order() const noexcept {
6363
return this->_n_vertices;
6464
}
6565

@@ -568,7 +568,7 @@ class graph final {
568568
os << std::format(
569569
"type: {}\nnumber of vertices: {}\nnumber of edges: {}\nvertices:\n",
570570
_directed_type_str(),
571-
this->n_vertices(),
571+
this->order(),
572572
this->n_edges()
573573
);
574574

@@ -580,7 +580,7 @@ class graph final {
580580
}
581581

582582
void _concise_write(std::ostream& os) const {
583-
os << std::format("{} {} {}\n", _directed_type_str(), this->n_vertices(), this->n_edges());
583+
os << std::format("{} {} {}\n", _directed_type_str(), this->order(), this->n_edges());
584584

585585
for (const auto& vertex : this->vertices()) {
586586
os << "- " << vertex << " :";
@@ -600,7 +600,7 @@ class graph final {
600600
os << std::format(
601601
"{} {} {} {} {}\n",
602602
static_cast<int>(type_traits::c_directed_edge<edge_type>),
603-
this->n_vertices(),
603+
this->order(),
604604
this->n_edges(),
605605
static_cast<int>(with_vertex_properties),
606606
static_cast<int>(with_edge_properties)

0 commit comments

Comments
 (0)