@@ -50,24 +50,12 @@ void saveAltData(const graph& gdata, const config& conf)
5050 }
5151
5252 {
53- uint64_t outer_size = static_cast <uint64_t >(gdata.dist_landmark_to .size ());
53+ uint64_t outer_size = static_cast <uint64_t >(gdata.dist_landmark .size ());
5454 ofs.write (reinterpret_cast <const char *>(&outer_size), sizeof (outer_size));
5555
56- for (const auto & row : gdata.dist_landmark_to ) {
56+ for (const auto & row : gdata.dist_landmark ) {
5757 uint64_t inner_size = static_cast <uint64_t >(row.size ());
5858 ofs.write (reinterpret_cast <const char *>(&inner_size), sizeof (inner_size));
59-
60- ofs.write (reinterpret_cast <const char *>(row.data ()), inner_size * sizeof (int ));
61- }
62- }
63- {
64- uint64_t outer_size = static_cast <uint64_t >(gdata.dist_landmark_from .size ());
65- ofs.write (reinterpret_cast <const char *>(&outer_size), sizeof (outer_size));
66-
67- for (const auto & row : gdata.dist_landmark_from ) {
68- uint64_t inner_size = static_cast <uint64_t >(row.size ());
69- ofs.write (reinterpret_cast <const char *>(&inner_size), sizeof (inner_size));
70-
7159 ofs.write (reinterpret_cast <const char *>(row.data ()), inner_size * sizeof (int ));
7260 }
7361 }
@@ -94,13 +82,10 @@ void saveAltData(const graph& gdata, const config& conf)
9482 * data from a binary file. The format must match the one used by `saveAltData`.
9583 *
9684 * Data Loaded:
97- * - dist_landmark_to :
85+ * - dist_landmark :
9886 * - Reads the number of nodes (outer size).
9987 * - For each node, reads the number of landmarks, then reads `int` distances.
10088 *
101- * - dist_landmark_from:
102- * - Same pattern as dist_landmark_to.
103- *
10489 * Steps of Execution:
10590 * 1. Open the input file in binary mode.
10691 * 2. Check if the file is empty (size == 0); if empty, return `false` to force preprocessing.
@@ -144,56 +129,27 @@ bool loadAltData(graph& gdata, config& conf)
144129 uint64_t outer_size = 0 ;
145130 ifs.read (reinterpret_cast <char *>(&outer_size), sizeof (outer_size));
146131 if (!ifs.good ()) {
147- console (" error" , " failed to read the size of dist_landmark_to, processing landmarks again" );
148- logger (" error: failed to read the size of dist_landmark_to, processing landmarks again." );
149- return false ;
150- }
151-
152- gdata.dist_landmark_to .resize (static_cast <size_t >(outer_size));
153- for (size_t i = 0 ; i < outer_size; ++i) {
154- uint64_t inner_size = 0 ;
155- ifs.read (reinterpret_cast <char *>(&inner_size), sizeof (inner_size));
156- if (!ifs.good ()) {
157- console (" error" , " failed to read the size of a dist_landmark_to row, processing landmarks again" );
158- logger (" error: failed to read the size of a dist_landmark_to row, processing landmarks again." );
159- return false ;
160- }
161-
162- gdata.dist_landmark_to [i].resize (static_cast <size_t >(inner_size));
163- ifs.read (reinterpret_cast <char *>(gdata.dist_landmark_to [i].data ()),
164- static_cast <std::streamsize>(inner_size * sizeof (int )));
165- if (!ifs.good ()) {
166- console (" error" , " failed to read dist_landmark_to row data, processing landmarks again" );
167- logger (" error: failed to read dist_landmark_to row data, processing landmarks again." );
168- return false ;
169- }
170- }
171- }
172- {
173- uint64_t outer_size = 0 ;
174- ifs.read (reinterpret_cast <char *>(&outer_size), sizeof (outer_size));
175- if (!ifs.good ()) {
176- console (" error" , " failed to read the size of dist_landmark_from, processing landmarks again" );
177- logger (" error: failed to read the size of dist_landmark_from, processing landmarks again." );
132+ console (" error" , " failed to read the size of dist_landmark, processing landmarks again" );
133+ logger (" error: failed to read the size of dist_landmark, processing landmarks again." );
178134 return false ;
179135 }
180136
181- gdata.dist_landmark_from .resize (static_cast <size_t >(outer_size));
137+ gdata.dist_landmark .resize (static_cast <size_t >(outer_size));
182138 for (size_t i = 0 ; i < outer_size; ++i) {
183139 uint64_t inner_size = 0 ;
184140 ifs.read (reinterpret_cast <char *>(&inner_size), sizeof (inner_size));
185141 if (!ifs.good ()) {
186- console (" error" , " failed to read the size of a dist_landmark_from row, processing landmarks again" );
187- logger (" error: failed to read the size of a dist_landmark_from row, processing landmarks again." );
142+ console (" error" , " failed to read the size of a dist_landmark row, processing landmarks again" );
143+ logger (" error: failed to read the size of a dist_landmark row, processing landmarks again." );
188144 return false ;
189145 }
190146
191- gdata.dist_landmark_from [i].resize (static_cast <size_t >(inner_size));
192- ifs.read (reinterpret_cast <char *>(gdata.dist_landmark_from [i].data ()),
193- static_cast <std::streamsize>(inner_size * sizeof (int )));
147+ gdata.dist_landmark [i].resize (static_cast <size_t >(inner_size));
148+ ifs.read (reinterpret_cast <char *>(gdata.dist_landmark [i].data ()),
149+ static_cast <std::streamsize>(inner_size * sizeof (int )));
194150 if (!ifs.good ()) {
195- console (" error" , " failed to read dist_landmark_from row data, processing landmarks again" );
196- logger (" error: failed to read dist_landmark_from row data, processing landmarks again" );
151+ console (" error" , " failed to read dist_landmark row data, processing landmarks again" );
152+ logger (" error: failed to read dist_landmark row data, processing landmarks again. " );
197153 return false ;
198154 }
199155 }
0 commit comments