From 7850cff75f19a58c77afee7c5dfb7a01fb1c6b09 Mon Sep 17 00:00:00 2001 From: Andrea Cassioli Date: Fri, 5 Dec 2025 22:16:37 +0100 Subject: [PATCH 1/4] use graph traits for number of vertices and edges; use unsigned size_t for loop indeces --- include/boost/graph/adj_list_serialize.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp index 85f7e2ed4..e3ee59a17 100644 --- a/include/boost/graph/adj_list_serialize.hpp +++ b/include/boost/graph/adj_list_serialize.hpp @@ -46,14 +46,16 @@ namespace serialization typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - int V = num_vertices(graph); - int E = num_edges(graph); + typedef typename boost::graph_traits::vertices_size_type VerticesSize; + + VerticesSize V = num_vertices(graph); + VerticesSize E = num_edges(graph); ar << BOOST_SERIALIZATION_NVP(V); ar << BOOST_SERIALIZATION_NVP(E); // assign indices to vertices - std::map< Vertex, int > indices; - int num = 0; + std::map< Vertex, size_t > indices; + size_t num = 0; BGL_FORALL_VERTICES_T(v, graph, Graph) { indices[v] = num++; @@ -91,7 +93,7 @@ namespace serialization ar >> BOOST_SERIALIZATION_NVP(E); std::vector< Vertex > verts(V); - int i = 0; + size_t i = 0; while (V-- > 0) { Vertex v = add_vertex(graph); @@ -101,8 +103,8 @@ namespace serialization } while (E-- > 0) { - int u; - int v; + Vertex u; + Vertex v; ar >> BOOST_SERIALIZATION_NVP(u); ar >> BOOST_SERIALIZATION_NVP(v); Edge e; From f593e09b3d630620affb64128a9c1a5eea2e0901 Mon Sep 17 00:00:00 2001 From: Andrea Cassioli Date: Fri, 5 Dec 2025 22:21:05 +0100 Subject: [PATCH 2/4] use graph traits for number of vertices and edges; use unsigned size_t for loops --- include/boost/graph/adj_list_serialize.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp index e3ee59a17..fe5145a84 100644 --- a/include/boost/graph/adj_list_serialize.hpp +++ b/include/boost/graph/adj_list_serialize.hpp @@ -45,8 +45,7 @@ namespace serialization { typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - - typedef typename boost::graph_traits::vertices_size_type VerticesSize; + typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; VerticesSize V = num_vertices(graph); VerticesSize E = num_edges(graph); @@ -86,10 +85,11 @@ namespace serialization typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::edge_descriptor Edge; + typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; - unsigned int V; + VerticesSize V; ar >> BOOST_SERIALIZATION_NVP(V); - unsigned int E; + VerticesSize E; ar >> BOOST_SERIALIZATION_NVP(E); std::vector< Vertex > verts(V); From 630590035d91acac7f738f09a4b5523701eac0dd Mon Sep 17 00:00:00 2001 From: Andrea Cassioli Date: Sat, 6 Dec 2025 22:34:48 +0100 Subject: [PATCH 3/4] use graph traits for number of edges; --- include/boost/graph/adj_list_serialize.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp index fe5145a84..b2bd1c78d 100644 --- a/include/boost/graph/adj_list_serialize.hpp +++ b/include/boost/graph/adj_list_serialize.hpp @@ -46,9 +46,10 @@ namespace serialization typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; + typedef typename graph_traits< Graph >::edges_size_type EdgesSize; VerticesSize V = num_vertices(graph); - VerticesSize E = num_edges(graph); + EdgesSize E = num_edges(graph); ar << BOOST_SERIALIZATION_NVP(V); ar << BOOST_SERIALIZATION_NVP(E); @@ -86,10 +87,11 @@ namespace serialization typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::edge_descriptor Edge; typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; + typedef typename graph_traits< Graph >::edges_size_type EdgesSize; VerticesSize V; ar >> BOOST_SERIALIZATION_NVP(V); - VerticesSize E; + EdgesSize E; ar >> BOOST_SERIALIZATION_NVP(E); std::vector< Vertex > verts(V); From 2d894ebe64fcf8ecb11f933a8f9cd948b54c8886 Mon Sep 17 00:00:00 2001 From: Andrea Cassioli Date: Sun, 28 Dec 2025 22:56:12 +0100 Subject: [PATCH 4/4] Cleanup and revert to use integers; --- include/boost/graph/adj_list_serialize.hpp | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp index b2bd1c78d..86fe15c7e 100644 --- a/include/boost/graph/adj_list_serialize.hpp +++ b/include/boost/graph/adj_list_serialize.hpp @@ -43,13 +43,11 @@ namespace serialization const unsigned int /* file_version */ ) { - typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; - typedef typename graph_traits< Graph >::edges_size_type EdgesSize; + using Graph = adjacency_list< OEL, VL, D, VP, EP, GP, EL >; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; - VerticesSize V = num_vertices(graph); - EdgesSize E = num_edges(graph); + unsigned int V = num_vertices(graph); + unsigned int E = num_edges(graph); ar << BOOST_SERIALIZATION_NVP(V); ar << BOOST_SERIALIZATION_NVP(E); @@ -83,15 +81,12 @@ namespace serialization const unsigned int /* file_version */ ) { - typedef adjacency_list< OEL, VL, D, VP, EP, GP, EL > Graph; - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename graph_traits< Graph >::edge_descriptor Edge; - typedef typename graph_traits< Graph >::vertices_size_type VerticesSize; - typedef typename graph_traits< Graph >::edges_size_type EdgesSize; + using Graph = adjacency_list< OEL, VL, D, VP, EP, GP, EL >; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; - VerticesSize V; + unsigned int V; ar >> BOOST_SERIALIZATION_NVP(V); - EdgesSize E; + unsigned int E; ar >> BOOST_SERIALIZATION_NVP(E); std::vector< Vertex > verts(V); @@ -109,9 +104,8 @@ namespace serialization Vertex v; ar >> BOOST_SERIALIZATION_NVP(u); ar >> BOOST_SERIALIZATION_NVP(v); - Edge e; - bool inserted; - boost::tie(e, inserted) = add_edge(verts[u], verts[v], graph); + + auto [e, inserted] = add_edge(verts[u], verts[v], graph); ar >> serialization::make_nvp( "edge_property", get(edge_all_t(), graph, e)); }