Skip to content

Commit d0470dd

Browse files
authored
Merge pull request #140 from stdgraph/remove_thirdpart_deps
Removing fmt and csv thirdparty dependency.
2 parents 1b834cb + e9f6fc0 commit d0470dd

23 files changed

+8775
-65
lines changed

.github/workflows/coverage.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
2020
if: "!contains(github.event.commits[0].message, '[skip cov]')"
2121
runs-on: ubuntu-latest
22+
container: ubuntu:24.04
2223

2324
# Steps represent a sequence of tasks that will be executed as part of the job
2425
steps:
2526
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2627
- uses: actions/checkout@v4
2728

28-
- run: sudo apt-get update && sudo apt-get install -y gcc-11 g++-11 lcov cmake git
29+
- run: apt-get update && apt-get install -y gcc-13 g++-13 lcov cmake git
2930
shell: bash
3031

3132
- name: Configure cmake
@@ -34,8 +35,8 @@ jobs:
3435
run: cmake -B ${{github.workspace}}/build -D ENABLE_COVERAGE=ON
3536
shell: bash
3637
env:
37-
CC: gcc-11
38-
CXX: g++-11
38+
CC: gcc-13
39+
CXX: g++-13
3940

4041
- name: Build all applications
4142
run: cmake --build ${{github.workspace}}/build
@@ -48,12 +49,12 @@ jobs:
4849
run: |
4950
cd ${{github.workspace}}/build
5051
lcov --no-external --capture --directory . --output-file coverage.info
51-
lcov --remove coverage.info '/usr/include/*' '*/tests/*' --output-file coverage.info
52+
lcov --ignore-errors unused --remove coverage.info '/usr/include/*' '*/tests/*' --output-file coverage.info
5253
geninfo --rc geninfo_unexecuted_blocks=1 --ignore-errors gcov --output-filename coverage.info .
5354
genhtml coverage.info --output-directory out
5455
5556
- name: Upload coverage reports to Codecov
56-
uses: codecov/codecov-action@v4
57+
uses: codecov/codecov-action@v5
5758
with:
5859
files: ${{github.workspace}}/build/out/index.html
5960
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/macos.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ jobs:
2525
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2626
- uses: actions/checkout@v4
2727

28-
- name: Install GCC-12
29-
run: brew install gcc@12
28+
- name: Install GCC-13
29+
run: brew install gcc@13
3030

3131
- name: Configure cmake
3232
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
3333
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
3434
run: cmake -B ${{github.workspace}}/build -D CMAKE_BUILD_TYPE=Release
3535
shell: bash
3636
env:
37-
CC: gcc-12
38-
CXX: g++-12
37+
CC: gcc-13
38+
CXX: g++-13
3939

4040
- name: Build all applications
4141
run: cmake --build ${{github.workspace}}/build
42+
43+
- name: Run tests
44+
run: ctest --test-dir ${{github.workspace}}/build/tests

.github/workflows/windows.yml

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ jobs:
3232

3333
- name: Build all applications
3434
run: cmake --build ${{github.workspace}}/build
35+
36+
- name: Run tests
37+
run: ctest -C Debug --test-dir ${{github.workspace}}/build/tests

CMakeLists.txt

+1-10
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,11 @@ if (ENABLE_PCH)
7878
endif()
7979

8080

81-
# Add libraries. Order is important based on dependencies.
82-
include(${PROJECT_SOURCE_DIR}/cmake/FetchFMT.cmake)
81+
# Add thirdparty libraries
8382
include(${PROJECT_SOURCE_DIR}/cmake/FetchCatch.cmake)
84-
include(${PROJECT_SOURCE_DIR}/cmake/FetchDocopt.cmake)
85-
include(${PROJECT_SOURCE_DIR}/cmake/FetchCSVParser.cmake)
86-
#include(${PROJECT_SOURCE_DIR}/cmake/FetchRange.cmake)
87-
#include(${PROJECT_SOURCE_DIR}/cmake/FetchSPDLog.cmake)
88-
#include(${PROJECT_SOURCE_DIR}/cmake/FetchBoost.cmake)
89-
9083

9184
add_library(graph INTERFACE)
9285
target_include_directories(graph INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/")
93-
target_link_libraries(graph INTERFACE fmt::fmt)
94-
#target_link_libraries(graph INTERFACE Boost::cobalt) # for coroutine library
9586

9687
if(ENABLE_TESTING)
9788
enable_testing()

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ Other releases or compilers may or may not work.
4343

4444
### Prerequesites
4545
- C\+\+20 compliant compiler that fully supports concepts and ranges. (C\+\+23 is required for building the benchmarks.)
46-
- CMake 26 or later (for CMake Presets)
46+
- CMake 3.20 or later (for CMake Presets)
4747

4848
### Quick Start Guide (Linux, WSL, MacOS)
4949
```bash
5050
git clone https://github.com/stdgraph/graph-v2.git
5151
cd graph-v2
5252
mkdir build && cd build
5353
cmake ..
54-
make -j8
54+
make
5555
```
5656

5757
### Editor/IDE Configuration (Windows)
@@ -123,5 +123,5 @@ The following papers make up the current proposal for the Graph Library.
123123
Committee ([WG21](https://isocpp.org/std/the-committee)).
124124
- Bob Steagal for his [gcc-builder & clang-builder scripts](https://github.com/BobSteagall)
125125
- Jason Turner for his [cpp_starter_project](https://github.com/lefticus/cpp_starter_project)
126-
- Vincent La for his [cvs-parser](https://github.com/vincentlaucsb/csv-parser)
126+
- Vincent La for his [cvs-parser](https://github.com/vincentlaucsb/csv-parser) (copied into tests).
127127
- The ISO C++ Standards Committee (WG21) for [C++](http://eel.is/c++draft/)

cmake/FetchCatch.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ message(STATUS "Cloning External Project: catch2")
66
FetchContent_Declare(
77
catch2
88
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
9-
GIT_TAG v3.5.2
9+
GIT_TAG v3.7.1
1010
)
1111
FetchContent_MakeAvailable(catch2)
1212
set(CATCH2_SOURCE_DIR "${catch2_SOURCE_DIR}")

example/CppCon2021/examples/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ add_executable(bacon "bacon.cpp")
77
target_link_libraries(bacon PRIVATE cppcon21_headers project_warnings project_options graph)
88

99
add_executable(ospf "ospf.cpp")
10-
target_link_libraries(ospf PRIVATE cppcon21_headers project_warnings project_options graph fmt::fmt)
10+
target_link_libraries(ospf PRIVATE cppcon21_headers project_warnings project_options graph)
1111

1212
add_executable(imdb "imdb.cpp")
1313
target_link_libraries(imdb PRIVATE cppcon21_headers project_warnings project_options graph)

example/CppCon2021/examples/graphs.cpp

+131-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <list>
2121
#include <vector>
22+
#include <iostream>
23+
#include <iomanip>
2224

2325
//#include "bfs_edge_range.hpp"
2426
#include "graph/graph.hpp"
@@ -30,8 +32,6 @@
3032
#include "spice-graph.hpp"
3133
#include "utilities.hpp"
3234

33-
#include <vector>
34-
3535
int main() {
3636

3737
/**
@@ -40,34 +40,150 @@ int main() {
4040
std::vector<std::vector<size_t>> G(34);
4141
push_back_plain_fill(karate_index_edge_list, G, false, 0);
4242
static_assert(graph::adjacency_list<decltype(G)>);
43+
std::cout << "Karate adjacency list:\n";
44+
std::cout << "size = " << G.size() << std::endl;
45+
for (size_t uid = 0; uid < G.size(); ++uid) {
46+
std::cout << std::setw(3) << uid << ":";
47+
for (auto&& vid : G[uid]) {
48+
std::cout << " " << vid;
49+
}
50+
std::cout << std::endl;
51+
}
4352

4453
std::vector<std::list<std::tuple<size_t>>> H(34);
4554
push_back_plain_fill(karate_index_edge_list, H, false, 0);
55+
std::cout << "\nKarate (edge_list plain fill):\n";
56+
std::cout << "size = " << H.size() << std::endl;
57+
for (size_t uid = 0; uid < H.size(); ++uid) {
58+
std::cout << std::setw(3) << uid << ":";
59+
for (auto&& [vid] : H[uid]) {
60+
std::cout << " " << vid;
61+
}
62+
std::cout << std::endl;
63+
}
64+
65+
4666
push_back_fill(karate_index_edge_list, H, false, 0);
67+
std::cout << "\nKarate (edge_list fill...adding more):\n";
68+
std::cout << "size = " << H.size() << std::endl;
69+
for (size_t uid = 0; uid < H.size(); ++uid) {
70+
std::cout << std::setw(3) << uid << ":";
71+
for (auto&& [vid] : H[uid]) {
72+
std::cout << " " << vid;
73+
}
74+
std::cout << std::endl;
75+
}
76+
77+
//----------------------------------------------------------------------------
4778

4879
/**
4980
* Other graphs have vertices and edges tables
5081
*/
5182
auto a = make_plain_graph(ospf_vertices, ospf_edges);
83+
std::cout << "\nOSPF plain graph:\n";
84+
std::cout << "size = " << a.size() << std::endl;
85+
for (size_t uid = 0; uid < a.size(); ++uid) {
86+
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
87+
for (auto&& vid : a[uid]) {
88+
std::cout << " " << ospf_vertices[vid];
89+
}
90+
std::cout << std::endl;
91+
}
92+
5293
auto b = make_property_graph(ospf_vertices, ospf_edges);
94+
std::cout << "\nOSPF property graph:\n";
95+
std::cout << "size = " << b.size() << std::endl;
96+
for (size_t uid = 0; uid < b.size(); ++uid) {
97+
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
98+
for (auto&& [vid, val] : b[uid]) {
99+
std::cout << " " << ospf_vertices[vid] << ":" << val;
100+
}
101+
std::cout << std::endl;
102+
}
103+
53104
auto c = make_index_graph(ospf_vertices, ospf_edges);
105+
std::cout << "\nOSPF index graph:\n";
106+
std::cout << "size = " << c.size() << std::endl;
107+
for (size_t uid = 0; uid < c.size(); ++uid) {
108+
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
109+
for (auto&& [vid, val] : c[uid]) {
110+
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
111+
}
112+
std::cout << std::endl;
113+
}
54114

55115
auto d = make_plain_graph<decltype(ospf_vertices), decltype(ospf_edges), std::vector<std::list<size_t>>>(
56116
ospf_vertices, ospf_edges, true);
117+
std::cout << "\nOSPF plain graph (vector of lists):\n";
118+
std::cout << "size = " << d.size() << std::endl;
119+
for (size_t uid = 0; uid < d.size(); ++uid) {
120+
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
121+
for (auto&& vid : d[uid]) {
122+
std::cout << " " << ospf_vertices[vid];
123+
}
124+
std::cout << std::endl;
125+
}
57126

58127
auto e = make_index_graph<decltype(ospf_vertices), decltype(ospf_edges),
59128
std::vector<std::vector<std::tuple<size_t, size_t>>>>(ospf_vertices, ospf_edges, true);
129+
std::cout << "\nOSPF index graph (vector of vector of tuples):\n";
130+
std::cout << "size = " << e.size() << std::endl;
131+
for (size_t uid = 0; uid < e.size(); ++uid) {
132+
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
133+
for (auto&& [vid, val] : e[uid]) {
134+
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
135+
}
136+
std::cout << std::endl;
137+
}
138+
139+
//----------------------------------------------------------------------------
60140

61141
auto [f, g] = make_plain_bipartite_graphs<>(movies, actors, movies_actors);
62142
auto h = make_plain_bipartite_graph(movies, actors, movies_actors, 0);
63143
auto i = make_plain_bipartite_graph(movies, actors, movies_actors, 1);
144+
std::cout << "\nMovies-actors plain bipartite graphs\n";
145+
std::cout << "index 0: " << f.size() << "==" << h.size() << std::endl;
146+
for (size_t uid = 0; uid < f.size(); ++uid) {
147+
std::cout << std::setw(20) << movies[uid] << ": |";
148+
for (auto&& vid : f[uid]) {
149+
std::cout << actors[vid] << "|";
150+
}
151+
std::cout << std::endl;
152+
}
153+
std::cout << "index 1: " << g.size() << "==" << i.size() << std::endl;
154+
for (size_t uid = 0; uid < g.size(); ++uid) {
155+
std::cout << std::setw(20) << actors[uid] << ": |";
156+
for (auto&& vid : g[uid]) {
157+
std::cout << movies[vid] << "|";
158+
}
159+
std::cout << std::endl;
160+
}
64161

65162
auto [j, k] = make_plain_bipartite_graphs<decltype(movies), decltype(actors), decltype(movies_actors),
66163
std::vector<std::list<size_t>>>(movies, actors, movies_actors);
67164
auto l = make_plain_bipartite_graph<decltype(movies), decltype(actors), decltype(movies_actors),
68165
std::vector<std::list<size_t>>>(movies, actors, movies_actors, 0);
69166
auto m = make_plain_bipartite_graph<decltype(movies), decltype(actors), decltype(movies_actors),
70167
std::vector<std::list<size_t>>>(movies, actors, movies_actors, 1);
168+
std::cout << "\nMovies-actors plain bipartite graphs (vector of lists)\n";
169+
std::cout << "index 0: " << j.size() << "==" << l.size() << std::endl;
170+
for (size_t uid = 0; uid < j.size(); ++uid) {
171+
std::cout << std::setw(20) << movies[uid] << ": |";
172+
for (auto&& vid : j[uid]) {
173+
std::cout << actors[vid] << "|";
174+
}
175+
std::cout << std::endl;
176+
}
177+
std::cout << "index 1: " << k.size() << "==" << m.size() << std::endl;
178+
for (size_t uid = 0; uid < k.size(); ++uid) {
179+
std::cout << std::setw(20) << actors[uid] << ": |";
180+
for (auto&& vid : k[uid]) {
181+
std::cout << movies[vid] << "|";
182+
}
183+
std::cout << std::endl;
184+
}
185+
186+
//----------------------------------------------------------------------------
71187

72188
auto n = make_plain_graph<decltype(spice_vertices), decltype(spice_edges), std::vector<std::list<int>>>(
73189
spice_vertices, spice_edges);
@@ -78,6 +194,19 @@ int main() {
78194
auto r = make_property_graph(spice_vertices, spice_edges);
79195
auto s = make_property_graph(spice_vertices, spice_edges_values);
80196

197+
std::cout << "\nSpice property graph (using edges+values)\n";
198+
std::cout << "Size: " << s.size() << std::endl;
199+
for (size_t uid = 0; uid < s.size(); ++uid) {
200+
std::cout << std::setw(4) << spice_vertices[uid] << ": |";
201+
for (auto&& [vid, comp, val] : s[uid]) {
202+
std::cout << std::setw(3) << spice_vertices[vid] << ":" << comp << "/" << val << "|";
203+
}
204+
std::cout << std::endl;
205+
}
206+
207+
208+
209+
81210
//bfs_edge_range(n, 1);
82211
graph::views::edges_breadth_first_search(n, 1);
83212

example/CppCon2021/examples/ospf.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ int main() {
5050
graph::init_shortest_paths(e, p);
5151
graph::dijkstra_shortest_paths(G, 5UL, e, p, [](auto&& ee) { return std::get<1>(ee); });
5252

53+
bool pass = true;
5354
for (size_t i = 0; i < size(ospf_vertices); ++i) {
54-
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
55+
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
56+
if (e[i] != d[i]) pass = false;
5557
}
58+
std::cout << (pass ? "***PASS***" : "***FAIL***") << std::endl;
5659

5760
std::cout << "----------------" << std::endl;
5861
std::cout << "Results from make_index_graph(osp_vertices)" << std::endl;
@@ -67,9 +70,12 @@ int main() {
6770
graph::init_shortest_paths(f, p);
6871
graph::dijkstra_shortest_paths(J, 5UL, f, p, [](auto&& ee) { return std::get<2>(ospf_edges[std::get<1>(ee)]); });
6972

73+
bool pass2 = true;
7074
for (size_t i = 0; i < size(ospf_vertices); ++i) {
7175
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
76+
if (e[i] != d[i]) pass2 = false;
7277
}
78+
std::cout << (pass2 ? "***PASS***" : "***FAIL***") << std::endl;
7379

7480
return 0;
7581
}

example/CppCon2021/include/utilities.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ auto make_plain_bipartite_graph(const V1& left_vertices, const V2& right_vertice
233233
auto index_edges = data_to_graph_edge_list(left_vertices, right_vertices, edges);
234234
auto graph_size = idx == 0 ? size(left_vertices) : size(right_vertices);
235235

236-
Graph G(size(left_vertices));
236+
Graph G(graph_size);
237237
push_back_plain_fill(index_edges, G, true, idx);
238238

239239
return G;

include/graph/algorithm/bellman_ford_shortest_paths.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <ranges>
2121
#include <optional>
2222
#include <stdexcept>
23-
#include <fmt/format.h>
23+
#include <format>
2424

2525
#ifndef GRAPH_BELLMAN_SHORTEST_PATHS_HPP
2626
# define GRAPH_BELLMAN_SHORTEST_PATHS_HPP
@@ -139,14 +139,14 @@ requires convertible_to<range_value_t<Sources>, vertex_id_t<G>> && //
139139

140140
if (size(distances) < size(vertices(g))) {
141141
throw std::out_of_range(
142-
fmt::format("bellman_ford_shortest_paths: size of distances is {} is less than the number of vertices {}",
142+
std::format("bellman_ford_shortest_paths: size of distances is {} is less than the number of vertices {}",
143143
size(distances), size(vertices(g))));
144144
}
145145

146146
if constexpr (!is_same_v<Predecessors, _null_range_type>) {
147147
if (size(predecessor) < size(vertices(g))) {
148148
throw std::out_of_range(
149-
fmt::format("bellman_ford_shortest_paths: size of predecessor is {} is less than the number of vertices {}",
149+
std::format("bellman_ford_shortest_paths: size of predecessor is {} is less than the number of vertices {}",
150150
size(predecessor), size(vertices(g))));
151151
}
152152
}
@@ -160,7 +160,7 @@ requires convertible_to<range_value_t<Sources>, vertex_id_t<G>> && //
160160
for (auto&& source : sources) {
161161
if (source >= N || source < 0) {
162162
throw std::out_of_range(
163-
fmt::format("bellman_ford_shortest_paths: source vertex id '{}' is out of range", source));
163+
std::format("bellman_ford_shortest_paths: source vertex id '{}' is out of range", source));
164164
}
165165
distances[static_cast<size_t>(source)] = zero; // mark source as discovered
166166
if constexpr (has_on_discover_vertex<G, Visitor>) {

0 commit comments

Comments
 (0)