388 |
388 |
389 template <typename Digraph> |
389 template <typename Digraph> |
390 class DigraphReader; |
390 class DigraphReader; |
391 |
391 |
392 template <typename Digraph> |
392 template <typename Digraph> |
393 DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph); |
393 DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
394 std::istream& is = std::cin); |
394 |
395 |
395 template <typename Digraph> |
396 template <typename Digraph> |
396 DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph); |
397 DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); |
397 |
398 |
398 template <typename Digraph> |
399 template <typename Digraph> |
399 DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph); |
400 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn); |
400 |
401 |
401 /// \ingroup lemon_io |
402 /// \ingroup lemon_io |
402 /// |
403 /// |
403 /// \brief \ref lgf-format "LGF" reader for directed graphs |
404 /// \brief \ref lgf-format "LGF" reader for directed graphs |
404 /// |
405 /// |
417 /// multiple map objects at the same time. The \c attribute(), \c |
418 /// multiple map objects at the same time. The \c attribute(), \c |
418 /// node() and \c arc() functions are used to add attribute reading |
419 /// node() and \c arc() functions are used to add attribute reading |
419 /// rules. |
420 /// rules. |
420 /// |
421 /// |
421 ///\code |
422 ///\code |
422 /// DigraphReader<Digraph>(std::cin, digraph). |
423 /// DigraphReader<Digraph>(digraph, std::cin). |
423 /// nodeMap("coordinates", coord_map). |
424 /// nodeMap("coordinates", coord_map). |
424 /// arcMap("capacity", cap_map). |
425 /// arcMap("capacity", cap_map). |
425 /// node("source", src). |
426 /// node("source", src). |
426 /// node("target", trg). |
427 /// node("target", trg). |
427 /// attribute("caption", caption). |
428 /// attribute("caption", caption). |
497 |
498 |
498 /// \brief Constructor |
499 /// \brief Constructor |
499 /// |
500 /// |
500 /// Construct a directed graph reader, which reads from the given |
501 /// Construct a directed graph reader, which reads from the given |
501 /// input stream. |
502 /// input stream. |
502 DigraphReader(std::istream& is, Digraph& digraph) |
503 DigraphReader(Digraph& digraph, std::istream& is = std::cin) |
503 : _is(&is), local_is(false), _digraph(digraph), |
504 : _is(&is), local_is(false), _digraph(digraph), |
504 _use_nodes(false), _use_arcs(false), |
505 _use_nodes(false), _use_arcs(false), |
505 _skip_nodes(false), _skip_arcs(false) {} |
506 _skip_nodes(false), _skip_arcs(false) {} |
506 |
507 |
507 /// \brief Constructor |
508 /// \brief Constructor |
508 /// |
509 /// |
509 /// Construct a directed graph reader, which reads from the given |
510 /// Construct a directed graph reader, which reads from the given |
510 /// file. |
511 /// file. |
511 DigraphReader(const std::string& fn, Digraph& digraph) |
512 DigraphReader(Digraph& digraph, const std::string& fn) |
512 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph), |
513 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph), |
513 _use_nodes(false), _use_arcs(false), |
514 _use_nodes(false), _use_arcs(false), |
514 _skip_nodes(false), _skip_arcs(false) {} |
515 _skip_nodes(false), _skip_arcs(false) {} |
515 |
516 |
516 /// \brief Constructor |
517 /// \brief Constructor |
517 /// |
518 /// |
518 /// Construct a directed graph reader, which reads from the given |
519 /// Construct a directed graph reader, which reads from the given |
519 /// file. |
520 /// file. |
520 DigraphReader(const char* fn, Digraph& digraph) |
521 DigraphReader(Digraph& digraph, const char* fn) |
521 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph), |
522 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph), |
522 _use_nodes(false), _use_arcs(false), |
523 _use_nodes(false), _use_arcs(false), |
523 _skip_nodes(false), _skip_arcs(false) {} |
524 _skip_nodes(false), _skip_arcs(false) {} |
524 |
525 |
525 /// \brief Destructor |
526 /// \brief Destructor |
545 |
546 |
546 } |
547 } |
547 |
548 |
548 private: |
549 private: |
549 |
550 |
550 friend DigraphReader<Digraph> digraphReader<>(std::istream& is, |
551 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, |
551 Digraph& digraph); |
552 std::istream& is); |
552 friend DigraphReader<Digraph> digraphReader<>(const std::string& fn, |
553 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, |
553 Digraph& digraph); |
554 const std::string& fn); |
554 friend DigraphReader<Digraph> digraphReader<>(const char *fn, |
555 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, |
555 Digraph& digraph); |
556 const char *fn); |
556 |
557 |
557 DigraphReader(DigraphReader& other) |
558 DigraphReader(DigraphReader& other) |
558 : _is(other._is), local_is(other.local_is), _digraph(other._digraph), |
559 : _is(other._is), local_is(other.local_is), _digraph(other._digraph), |
559 _use_nodes(other._use_nodes), _use_arcs(other._use_arcs), |
560 _use_nodes(other._use_nodes), _use_arcs(other._use_arcs), |
560 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { |
561 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { |
1178 /// \brief Return a \ref DigraphReader class |
1179 /// \brief Return a \ref DigraphReader class |
1179 /// |
1180 /// |
1180 /// This function just returns a \ref DigraphReader class. |
1181 /// This function just returns a \ref DigraphReader class. |
1181 /// \relates DigraphReader |
1182 /// \relates DigraphReader |
1182 template <typename Digraph> |
1183 template <typename Digraph> |
1183 DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) { |
1184 DigraphReader<Digraph> digraphReader(Digraph& digraph, |
1184 DigraphReader<Digraph> tmp(is, digraph); |
1185 std::istream& is = std::cin) { |
|
1186 DigraphReader<Digraph> tmp(digraph, is); |
1185 return tmp; |
1187 return tmp; |
1186 } |
1188 } |
1187 |
1189 |
1188 /// \brief Return a \ref DigraphReader class |
1190 /// \brief Return a \ref DigraphReader class |
1189 /// |
1191 /// |
1190 /// This function just returns a \ref DigraphReader class. |
1192 /// This function just returns a \ref DigraphReader class. |
1191 /// \relates DigraphReader |
1193 /// \relates DigraphReader |
1192 template <typename Digraph> |
1194 template <typename Digraph> |
1193 DigraphReader<Digraph> digraphReader(const std::string& fn, |
1195 DigraphReader<Digraph> digraphReader(Digraph& digraph, |
1194 Digraph& digraph) { |
1196 const std::string& fn) { |
1195 DigraphReader<Digraph> tmp(fn, digraph); |
1197 DigraphReader<Digraph> tmp(digraph, fn); |
1196 return tmp; |
1198 return tmp; |
1197 } |
1199 } |
1198 |
1200 |
1199 /// \brief Return a \ref DigraphReader class |
1201 /// \brief Return a \ref DigraphReader class |
1200 /// |
1202 /// |
1201 /// This function just returns a \ref DigraphReader class. |
1203 /// This function just returns a \ref DigraphReader class. |
1202 /// \relates DigraphReader |
1204 /// \relates DigraphReader |
1203 template <typename Digraph> |
1205 template <typename Digraph> |
1204 DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) { |
1206 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { |
1205 DigraphReader<Digraph> tmp(fn, digraph); |
1207 DigraphReader<Digraph> tmp(digraph, fn); |
1206 return tmp; |
1208 return tmp; |
1207 } |
1209 } |
1208 |
1210 |
1209 template <typename Graph> |
1211 template <typename Graph> |
1210 class GraphReader; |
1212 class GraphReader; |
1211 |
1213 |
1212 template <typename Graph> |
1214 template <typename Graph> |
1213 GraphReader<Graph> graphReader(std::istream& is, Graph& graph); |
1215 GraphReader<Graph> graphReader(Graph& graph, |
|
1216 std::istream& is = std::cin); |
1214 |
1217 |
1215 template <typename Graph> |
1218 template <typename Graph> |
1216 GraphReader<Graph> graphReader(const std::string& fn, Graph& graph); |
1219 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); |
1217 |
1220 |
1218 template <typename Graph> |
1221 template <typename Graph> |
1219 GraphReader<Graph> graphReader(const char *fn, Graph& graph); |
1222 GraphReader<Graph> graphReader(Graph& graph, const char *fn); |
1220 |
1223 |
1221 /// \ingroup lemon_io |
1224 /// \ingroup lemon_io |
1222 /// |
1225 /// |
1223 /// \brief \ref lgf-format "LGF" reader for undirected graphs |
1226 /// \brief \ref lgf-format "LGF" reader for undirected graphs |
1224 /// |
1227 /// |
1281 |
1284 |
1282 /// \brief Constructor |
1285 /// \brief Constructor |
1283 /// |
1286 /// |
1284 /// Construct an undirected graph reader, which reads from the given |
1287 /// Construct an undirected graph reader, which reads from the given |
1285 /// input stream. |
1288 /// input stream. |
1286 GraphReader(std::istream& is, Graph& graph) |
1289 GraphReader(Graph& graph, std::istream& is = std::cin) |
1287 : _is(&is), local_is(false), _graph(graph), |
1290 : _is(&is), local_is(false), _graph(graph), |
1288 _use_nodes(false), _use_edges(false), |
1291 _use_nodes(false), _use_edges(false), |
1289 _skip_nodes(false), _skip_edges(false) {} |
1292 _skip_nodes(false), _skip_edges(false) {} |
1290 |
1293 |
1291 /// \brief Constructor |
1294 /// \brief Constructor |
1292 /// |
1295 /// |
1293 /// Construct an undirected graph reader, which reads from the given |
1296 /// Construct an undirected graph reader, which reads from the given |
1294 /// file. |
1297 /// file. |
1295 GraphReader(const std::string& fn, Graph& graph) |
1298 GraphReader(Graph& graph, const std::string& fn) |
1296 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph), |
1299 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph), |
1297 _use_nodes(false), _use_edges(false), |
1300 _use_nodes(false), _use_edges(false), |
1298 _skip_nodes(false), _skip_edges(false) {} |
1301 _skip_nodes(false), _skip_edges(false) {} |
1299 |
1302 |
1300 /// \brief Constructor |
1303 /// \brief Constructor |
1301 /// |
1304 /// |
1302 /// Construct an undirected graph reader, which reads from the given |
1305 /// Construct an undirected graph reader, which reads from the given |
1303 /// file. |
1306 /// file. |
1304 GraphReader(const char* fn, Graph& graph) |
1307 GraphReader(Graph& graph, const char* fn) |
1305 : _is(new std::ifstream(fn)), local_is(true), _graph(graph), |
1308 : _is(new std::ifstream(fn)), local_is(true), _graph(graph), |
1306 _use_nodes(false), _use_edges(false), |
1309 _use_nodes(false), _use_edges(false), |
1307 _skip_nodes(false), _skip_edges(false) {} |
1310 _skip_nodes(false), _skip_edges(false) {} |
1308 |
1311 |
1309 /// \brief Destructor |
1312 /// \brief Destructor |
1328 } |
1331 } |
1329 |
1332 |
1330 } |
1333 } |
1331 |
1334 |
1332 private: |
1335 private: |
1333 friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph); |
1336 friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is); |
1334 friend GraphReader<Graph> graphReader<>(const std::string& fn, |
1337 friend GraphReader<Graph> graphReader<>(Graph& graph, |
1335 Graph& graph); |
1338 const std::string& fn); |
1336 friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph); |
1339 friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn); |
1337 |
1340 |
1338 GraphReader(GraphReader& other) |
1341 GraphReader(GraphReader& other) |
1339 : _is(other._is), local_is(other.local_is), _graph(other._graph), |
1342 : _is(other._is), local_is(other.local_is), _graph(other._graph), |
1340 _use_nodes(other._use_nodes), _use_edges(other._use_edges), |
1343 _use_nodes(other._use_nodes), _use_edges(other._use_edges), |
1341 _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) { |
1344 _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) { |
2004 /// \brief Return a \ref GraphReader class |
2007 /// \brief Return a \ref GraphReader class |
2005 /// |
2008 /// |
2006 /// This function just returns a \ref GraphReader class. |
2009 /// This function just returns a \ref GraphReader class. |
2007 /// \relates GraphReader |
2010 /// \relates GraphReader |
2008 template <typename Graph> |
2011 template <typename Graph> |
2009 GraphReader<Graph> graphReader(std::istream& is, Graph& graph) { |
2012 GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { |
2010 GraphReader<Graph> tmp(is, graph); |
2013 GraphReader<Graph> tmp(graph, is); |
2011 return tmp; |
2014 return tmp; |
2012 } |
2015 } |
2013 |
2016 |
2014 /// \brief Return a \ref GraphReader class |
2017 /// \brief Return a \ref GraphReader class |
2015 /// |
2018 /// |
2016 /// This function just returns a \ref GraphReader class. |
2019 /// This function just returns a \ref GraphReader class. |
2017 /// \relates GraphReader |
2020 /// \relates GraphReader |
2018 template <typename Graph> |
2021 template <typename Graph> |
2019 GraphReader<Graph> graphReader(const std::string& fn, |
2022 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { |
2020 Graph& graph) { |
2023 GraphReader<Graph> tmp(graph, fn); |
2021 GraphReader<Graph> tmp(fn, graph); |
|
2022 return tmp; |
2024 return tmp; |
2023 } |
2025 } |
2024 |
2026 |
2025 /// \brief Return a \ref GraphReader class |
2027 /// \brief Return a \ref GraphReader class |
2026 /// |
2028 /// |
2027 /// This function just returns a \ref GraphReader class. |
2029 /// This function just returns a \ref GraphReader class. |
2028 /// \relates GraphReader |
2030 /// \relates GraphReader |
2029 template <typename Graph> |
2031 template <typename Graph> |
2030 GraphReader<Graph> graphReader(const char* fn, Graph& graph) { |
2032 GraphReader<Graph> graphReader(Graph& graph, const char* fn) { |
2031 GraphReader<Graph> tmp(fn, graph); |
2033 GraphReader<Graph> tmp(graph, fn); |
2032 return tmp; |
2034 return tmp; |
2033 } |
2035 } |
2034 |
2036 |
2035 class SectionReader; |
2037 class SectionReader; |
2036 |
2038 |