0
2
0
165
104
144
86
| ... | ... |
@@ -103,5 +103,5 @@ |
| 103 | 103 |
|
| 104 |
template <typename |
|
| 104 |
template <typename _GR, bool _dir, typename _Map, |
|
| 105 | 105 |
typename _Converter = DefaultConverter<typename _Map::Value> > |
| 106 |
class GraphArcMapStorage : public MapStorageBase<typename |
|
| 106 |
class GraphArcMapStorage : public MapStorageBase<typename _GR::Edge> {
|
|
| 107 | 107 |
public: |
| ... | ... |
@@ -109,4 +109,4 @@ |
| 109 | 109 |
typedef _Converter Converter; |
| 110 |
typedef _Graph Graph; |
|
| 111 |
typedef typename Graph::Edge Item; |
|
| 110 |
typedef _GR GR; |
|
| 111 |
typedef typename GR::Edge Item; |
|
| 112 | 112 |
static const bool dir = _dir; |
| ... | ... |
@@ -114,3 +114,3 @@ |
| 114 | 114 |
private: |
| 115 |
const |
|
| 115 |
const GR& _graph; |
|
| 116 | 116 |
Map& _map; |
| ... | ... |
@@ -119,3 +119,3 @@ |
| 119 | 119 |
public: |
| 120 |
GraphArcMapStorage(const |
|
| 120 |
GraphArcMapStorage(const GR& graph, Map& map, |
|
| 121 | 121 |
const Converter& converter = Converter()) |
| ... | ... |
@@ -175,13 +175,13 @@ |
| 175 | 175 |
|
| 176 |
template <typename |
|
| 176 |
template <typename GR> |
|
| 177 | 177 |
struct GraphArcLookUpConverter {
|
| 178 |
const Graph& _graph; |
|
| 179 |
const std::map<std::string, typename Graph::Edge>& _map; |
|
| 180 |
|
|
| 181 |
GraphArcLookUpConverter(const Graph& graph, |
|
| 178 |
const GR& _graph; |
|
| 179 |
const std::map<std::string, typename GR::Edge>& _map; |
|
| 180 |
|
|
| 181 |
GraphArcLookUpConverter(const GR& graph, |
|
| 182 | 182 |
const std::map<std::string, |
| 183 |
typename |
|
| 183 |
typename GR::Edge>& map) |
|
| 184 | 184 |
: _graph(graph), _map(map) {}
|
| 185 | 185 |
|
| 186 |
typename |
|
| 186 |
typename GR::Arc operator()(const std::string& str) {
|
|
| 187 | 187 |
if (str.empty() || (str[0] != '+' && str[0] != '-')) {
|
| ... | ... |
@@ -189,3 +189,3 @@ |
| 189 | 189 |
} |
| 190 |
typename std::map<std::string, typename |
|
| 190 |
typename std::map<std::string, typename GR::Edge> |
|
| 191 | 191 |
::const_iterator it = _map.find(str.substr(1)); |
| ... | ... |
@@ -389,12 +389,11 @@ |
| 389 | 389 |
|
| 390 |
template <typename |
|
| 390 |
template <typename DGR> |
|
| 391 | 391 |
class DigraphReader; |
| 392 | 392 |
|
| 393 |
template <typename Digraph> |
|
| 394 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
| 395 |
std::istream& is = std::cin); |
|
| 396 |
template <typename Digraph> |
|
| 397 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); |
|
| 398 |
template <typename Digraph> |
|
| 399 |
|
|
| 393 |
template <typename TDGR> |
|
| 394 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is = std::cin); |
|
| 395 |
template <typename TDGR> |
|
| 396 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn); |
|
| 397 |
template <typename TDGR> |
|
| 398 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn); |
|
| 400 | 399 |
|
| ... | ... |
@@ -421,3 +420,3 @@ |
| 421 | 420 |
///\code |
| 422 |
/// DigraphReader< |
|
| 421 |
/// DigraphReader<DGR>(digraph, std::cin). |
|
| 423 | 422 |
/// nodeMap("coordinates", coord_map).
|
| ... | ... |
@@ -450,3 +449,3 @@ |
| 450 | 449 |
/// maps are read. |
| 451 |
template <typename |
|
| 450 |
template <typename DGR> |
|
| 452 | 451 |
class DigraphReader {
|
| ... | ... |
@@ -454,3 +453,3 @@ |
| 454 | 453 |
|
| 455 |
typedef |
|
| 454 |
typedef DGR Digraph; |
|
| 456 | 455 |
|
| ... | ... |
@@ -458,3 +457,3 @@ |
| 458 | 457 |
|
| 459 |
TEMPLATE_DIGRAPH_TYPEDEFS( |
|
| 458 |
TEMPLATE_DIGRAPH_TYPEDEFS(DGR); |
|
| 460 | 459 |
|
| ... | ... |
@@ -464,3 +463,3 @@ |
| 464 | 463 |
|
| 465 |
|
|
| 464 |
DGR& _digraph; |
|
| 466 | 465 |
|
| ... | ... |
@@ -502,3 +501,3 @@ |
| 502 | 501 |
/// input stream. |
| 503 |
DigraphReader( |
|
| 502 |
DigraphReader(DGR& digraph, std::istream& is = std::cin) |
|
| 504 | 503 |
: _is(&is), local_is(false), _digraph(digraph), |
| ... | ... |
@@ -511,3 +510,3 @@ |
| 511 | 510 |
/// file. |
| 512 |
DigraphReader( |
|
| 511 |
DigraphReader(DGR& digraph, const std::string& fn) |
|
| 513 | 512 |
: _is(new std::ifstream(fn.c_str())), local_is(true), |
| ... | ... |
@@ -526,3 +525,3 @@ |
| 526 | 525 |
/// file. |
| 527 |
DigraphReader( |
|
| 526 |
DigraphReader(DGR& digraph, const char* fn) |
|
| 528 | 527 |
: _is(new std::ifstream(fn)), local_is(true), |
| ... | ... |
@@ -562,9 +561,9 @@ |
| 562 | 561 |
|
| 563 |
template <typename DGR> |
|
| 564 |
friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is); |
|
| 565 |
template <typename DGR> |
|
| 566 |
friend DigraphReader<DGR> digraphReader(DGR& digraph, |
|
| 567 |
const std::string& fn); |
|
| 568 |
template <typename DGR> |
|
| 569 |
|
|
| 562 |
template <typename TDGR> |
|
| 563 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is); |
|
| 564 |
template <typename TDGR> |
|
| 565 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, |
|
| 566 |
const std::string& fn); |
|
| 567 |
template <typename TDGR> |
|
| 568 |
friend DigraphReader<TDGR> digraphReader(TDGR& digraph, const char *fn); |
|
| 570 | 569 |
|
| ... | ... |
@@ -1190,2 +1189,39 @@ |
| 1190 | 1189 |
}; |
| 1190 |
|
|
| 1191 |
/// \ingroup lemon_io |
|
| 1192 |
/// |
|
| 1193 |
/// \brief Return a \ref DigraphReader class |
|
| 1194 |
/// |
|
| 1195 |
/// This function just returns a \ref DigraphReader class. |
|
| 1196 |
/// |
|
| 1197 |
/// With this function a digraph can be read from an |
|
| 1198 |
/// \ref lgf-format "LGF" file or input stream with several maps and |
|
| 1199 |
/// attributes. For example, there is network flow problem on a |
|
| 1200 |
/// digraph, i.e. a digraph with a \e capacity map on the arcs and |
|
| 1201 |
/// \e source and \e target nodes. This digraph can be read with the |
|
| 1202 |
/// following code: |
|
| 1203 |
/// |
|
| 1204 |
///\code |
|
| 1205 |
///ListDigraph digraph; |
|
| 1206 |
///ListDigraph::ArcMap<int> cm(digraph); |
|
| 1207 |
///ListDigraph::Node src, trg; |
|
| 1208 |
///digraphReader(digraph, std::cin). |
|
| 1209 |
/// arcMap("capacity", cap).
|
|
| 1210 |
/// node("source", src).
|
|
| 1211 |
/// node("target", trg).
|
|
| 1212 |
/// run(); |
|
| 1213 |
///\endcode |
|
| 1214 |
/// |
|
| 1215 |
/// For a complete documentation, please see the \ref DigraphReader |
|
| 1216 |
/// class documentation. |
|
| 1217 |
/// \warning Don't forget to put the \ref DigraphReader::run() "run()" |
|
| 1218 |
/// to the end of the parameter list. |
|
| 1219 |
/// \relates DigraphReader |
|
| 1220 |
/// \sa digraphReader(TDGR& digraph, const std::string& fn) |
|
| 1221 |
/// \sa digraphReader(TDGR& digraph, const char* fn) |
|
| 1222 |
template <typename TDGR> |
|
| 1223 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, std::istream& is) {
|
|
| 1224 |
DigraphReader<TDGR> tmp(digraph, is); |
|
| 1225 |
return tmp; |
|
| 1226 |
} |
|
| 1191 | 1227 |
|
| ... | ... |
@@ -1195,5 +1231,6 @@ |
| 1195 | 1231 |
/// \relates DigraphReader |
| 1196 |
template <typename Digraph> |
|
| 1197 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
|
|
| 1198 |
|
|
| 1232 |
/// \sa digraphReader(TDGR& digraph, std::istream& is) |
|
| 1233 |
template <typename TDGR> |
|
| 1234 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, const std::string& fn) {
|
|
| 1235 |
DigraphReader<TDGR> tmp(digraph, fn); |
|
| 1199 | 1236 |
return tmp; |
| ... | ... |
@@ -1205,6 +1242,6 @@ |
| 1205 | 1242 |
/// \relates DigraphReader |
| 1206 |
template <typename Digraph> |
|
| 1207 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
| 1208 |
const std::string& fn) {
|
|
| 1209 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
| 1243 |
/// \sa digraphReader(TDGR& digraph, std::istream& is) |
|
| 1244 |
template <typename TDGR> |
|
| 1245 |
DigraphReader<TDGR> digraphReader(TDGR& digraph, const char* fn) {
|
|
| 1246 |
DigraphReader<TDGR> tmp(digraph, fn); |
|
| 1210 | 1247 |
return tmp; |
| ... | ... |
@@ -1212,22 +1249,11 @@ |
| 1212 | 1249 |
|
| 1213 |
/// \brief Return a \ref DigraphReader class |
|
| 1214 |
/// |
|
| 1215 |
/// This function just returns a \ref DigraphReader class. |
|
| 1216 |
/// \relates DigraphReader |
|
| 1217 |
template <typename Digraph> |
|
| 1218 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
|
|
| 1219 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
| 1220 |
return tmp; |
|
| 1221 |
} |
|
| 1222 |
|
|
| 1223 |
template <typename |
|
| 1250 |
template <typename GR> |
|
| 1224 | 1251 |
class GraphReader; |
| 1225 | 1252 |
|
| 1226 |
template <typename Graph> |
|
| 1227 |
GraphReader<Graph> graphReader(Graph& graph, |
|
| 1228 |
std::istream& is = std::cin); |
|
| 1229 |
template <typename Graph> |
|
| 1230 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); |
|
| 1231 |
template <typename Graph> |
|
| 1232 |
|
|
| 1253 |
template <typename TGR> |
|
| 1254 |
GraphReader<TGR> graphReader(TGR& graph, std::istream& is = std::cin); |
|
| 1255 |
template <typename TGR> |
|
| 1256 |
GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); |
|
| 1257 |
template <typename TGR> |
|
| 1258 |
GraphReader<TGR> graphReader(TGR& graph, const char *fn); |
|
| 1233 | 1259 |
|
| ... | ... |
@@ -1256,3 +1282,3 @@ |
| 1256 | 1282 |
|
| 1257 |
TEMPLATE_GRAPH_TYPEDEFS( |
|
| 1283 |
TEMPLATE_GRAPH_TYPEDEFS(GR); |
|
| 1258 | 1284 |
|
| ... | ... |
@@ -1262,3 +1288,3 @@ |
| 1262 | 1288 |
|
| 1263 |
|
|
| 1289 |
GR& _graph; |
|
| 1264 | 1290 |
|
| ... | ... |
@@ -1300,3 +1326,3 @@ |
| 1300 | 1326 |
/// input stream. |
| 1301 |
GraphReader( |
|
| 1327 |
GraphReader(GR& graph, std::istream& is = std::cin) |
|
| 1302 | 1328 |
: _is(&is), local_is(false), _graph(graph), |
| ... | ... |
@@ -1309,3 +1335,3 @@ |
| 1309 | 1335 |
/// file. |
| 1310 |
GraphReader( |
|
| 1336 |
GraphReader(GR& graph, const std::string& fn) |
|
| 1311 | 1337 |
: _is(new std::ifstream(fn.c_str())), local_is(true), |
| ... | ... |
@@ -1324,3 +1350,3 @@ |
| 1324 | 1350 |
/// file. |
| 1325 |
GraphReader( |
|
| 1351 |
GraphReader(GR& graph, const char* fn) |
|
| 1326 | 1352 |
: _is(new std::ifstream(fn)), local_is(true), |
| ... | ... |
@@ -1359,8 +1385,8 @@ |
| 1359 | 1385 |
private: |
| 1360 |
template <typename Graph> |
|
| 1361 |
friend GraphReader<Graph> graphReader(Graph& graph, std::istream& is); |
|
| 1362 |
template <typename Graph> |
|
| 1363 |
friend GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); |
|
| 1364 |
template <typename Graph> |
|
| 1365 |
friend GraphReader<Graph> graphReader(Graph& graph, const char *fn); |
|
| 1386 |
template <typename TGR> |
|
| 1387 |
friend GraphReader<TGR> graphReader(TGR& graph, std::istream& is); |
|
| 1388 |
template <typename TGR> |
|
| 1389 |
friend GraphReader<TGR> graphReader(TGR& graph, const std::string& fn); |
|
| 1390 |
template <typename TGR> |
|
| 1391 |
friend GraphReader<TGR> graphReader(TGR& graph, const char *fn); |
|
| 1366 | 1392 |
|
| ... | ... |
@@ -1456,3 +1482,3 @@ |
| 1456 | 1482 |
_reader_bits::MapStorageBase<Edge>* backward_storage = |
| 1457 |
new _reader_bits::GraphArcMapStorage< |
|
| 1483 |
new _reader_bits::GraphArcMapStorage<GR, false, Map>(_graph, map); |
|
| 1458 | 1484 |
_edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
|
| ... | ... |
@@ -1470,3 +1496,3 @@ |
| 1470 | 1496 |
_reader_bits::MapStorageBase<Edge>* forward_storage = |
| 1471 |
new _reader_bits::GraphArcMapStorage< |
|
| 1497 |
new _reader_bits::GraphArcMapStorage<GR, true, Map, Converter> |
|
| 1472 | 1498 |
(_graph, map, converter); |
| ... | ... |
@@ -1474,3 +1500,3 @@ |
| 1474 | 1500 |
_reader_bits::MapStorageBase<Edge>* backward_storage = |
| 1475 |
new _reader_bits::GraphArcMapStorage< |
|
| 1501 |
new _reader_bits::GraphArcMapStorage<GR, false, Map, Converter> |
|
| 1476 | 1502 |
(_graph, map, converter); |
| ... | ... |
@@ -1532,3 +1558,3 @@ |
| 1532 | 1558 |
GraphReader& arc(const std::string& caption, Arc& arc) {
|
| 1533 |
typedef _reader_bits::GraphArcLookUpConverter< |
|
| 1559 |
typedef _reader_bits::GraphArcLookUpConverter<GR> Converter; |
|
| 1534 | 1560 |
Converter converter(_graph, _edge_index); |
| ... | ... |
@@ -2035,2 +2061,35 @@ |
| 2035 | 2061 |
|
| 2062 |
/// \ingroup lemon_io |
|
| 2063 |
/// |
|
| 2064 |
/// \brief Return a \ref GraphReader class |
|
| 2065 |
/// |
|
| 2066 |
/// This function just returns a \ref GraphReader class. |
|
| 2067 |
/// |
|
| 2068 |
/// With this function a graph can be read from an |
|
| 2069 |
/// \ref lgf-format "LGF" file or input stream with several maps and |
|
| 2070 |
/// attributes. For example, there is weighted matching problem on a |
|
| 2071 |
/// graph, i.e. a graph with a \e weight map on the edges. This |
|
| 2072 |
/// graph can be read with the following code: |
|
| 2073 |
/// |
|
| 2074 |
///\code |
|
| 2075 |
///ListGraph graph; |
|
| 2076 |
///ListGraph::EdgeMap<int> weight(graph); |
|
| 2077 |
///graphReader(graph, std::cin). |
|
| 2078 |
/// edgeMap("weight", weight).
|
|
| 2079 |
/// run(); |
|
| 2080 |
///\endcode |
|
| 2081 |
/// |
|
| 2082 |
/// For a complete documentation, please see the \ref GraphReader |
|
| 2083 |
/// class documentation. |
|
| 2084 |
/// \warning Don't forget to put the \ref GraphReader::run() "run()" |
|
| 2085 |
/// to the end of the parameter list. |
|
| 2086 |
/// \relates GraphReader |
|
| 2087 |
/// \sa graphReader(TGR& graph, const std::string& fn) |
|
| 2088 |
/// \sa graphReader(TGR& graph, const char* fn) |
|
| 2089 |
template <typename TGR> |
|
| 2090 |
GraphReader<TGR> graphReader(TGR& graph, std::istream& is) {
|
|
| 2091 |
GraphReader<TGR> tmp(graph, is); |
|
| 2092 |
return tmp; |
|
| 2093 |
} |
|
| 2094 |
|
|
| 2036 | 2095 |
/// \brief Return a \ref GraphReader class |
| ... | ... |
@@ -2039,5 +2098,6 @@ |
| 2039 | 2098 |
/// \relates GraphReader |
| 2040 |
template <typename Graph> |
|
| 2041 |
GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
|
|
| 2042 |
|
|
| 2099 |
/// \sa graphReader(TGR& graph, std::istream& is) |
|
| 2100 |
template <typename TGR> |
|
| 2101 |
GraphReader<TGR> graphReader(TGR& graph, const std::string& fn) {
|
|
| 2102 |
GraphReader<TGR> tmp(graph, fn); |
|
| 2043 | 2103 |
return tmp; |
| ... | ... |
@@ -2049,15 +2109,6 @@ |
| 2049 | 2109 |
/// \relates GraphReader |
| 2050 |
template <typename Graph> |
|
| 2051 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
|
|
| 2052 |
GraphReader<Graph> tmp(graph, fn); |
|
| 2053 |
return tmp; |
|
| 2054 |
} |
|
| 2055 |
|
|
| 2056 |
/// \brief Return a \ref GraphReader class |
|
| 2057 |
/// |
|
| 2058 |
/// This function just returns a \ref GraphReader class. |
|
| 2059 |
/// \relates GraphReader |
|
| 2060 |
template <typename Graph> |
|
| 2061 |
GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
|
|
| 2062 |
|
|
| 2110 |
/// \sa graphReader(TGR& graph, std::istream& is) |
|
| 2111 |
template <typename TGR> |
|
| 2112 |
GraphReader<TGR> graphReader(TGR& graph, const char* fn) {
|
|
| 2113 |
GraphReader<TGR> tmp(graph, fn); |
|
| 2063 | 2114 |
return tmp; |
| ... | ... |
@@ -2318,2 +2369,19 @@ |
| 2318 | 2369 |
|
| 2370 |
/// \ingroup lemon_io |
|
| 2371 |
/// |
|
| 2372 |
/// \brief Return a \ref SectionReader class |
|
| 2373 |
/// |
|
| 2374 |
/// This function just returns a \ref SectionReader class. |
|
| 2375 |
/// |
|
| 2376 |
/// Please see SectionReader documentation about the custom section |
|
| 2377 |
/// input. |
|
| 2378 |
/// |
|
| 2379 |
/// \relates SectionReader |
|
| 2380 |
/// \sa sectionReader(const std::string& fn) |
|
| 2381 |
/// \sa sectionReader(const char *fn) |
|
| 2382 |
inline SectionReader sectionReader(std::istream& is) {
|
|
| 2383 |
SectionReader tmp(is); |
|
| 2384 |
return tmp; |
|
| 2385 |
} |
|
| 2386 |
|
|
| 2319 | 2387 |
/// \brief Return a \ref SectionReader class |
| ... | ... |
@@ -2322,4 +2390,5 @@ |
| 2322 | 2390 |
/// \relates SectionReader |
| 2323 |
inline SectionReader sectionReader(std::istream& is) {
|
|
| 2324 |
SectionReader tmp(is); |
|
| 2391 |
/// \sa sectionReader(std::istream& is) |
|
| 2392 |
inline SectionReader sectionReader(const std::string& fn) {
|
|
| 2393 |
SectionReader tmp(fn); |
|
| 2325 | 2394 |
return tmp; |
| ... | ... |
@@ -2331,11 +2400,3 @@ |
| 2331 | 2400 |
/// \relates SectionReader |
| 2332 |
inline SectionReader sectionReader(const std::string& fn) {
|
|
| 2333 |
SectionReader tmp(fn); |
|
| 2334 |
return tmp; |
|
| 2335 |
} |
|
| 2336 |
|
|
| 2337 |
/// \brief Return a \ref SectionReader class |
|
| 2338 |
/// |
|
| 2339 |
/// This function just returns a \ref SectionReader class. |
|
| 2340 |
/// \ |
|
| 2401 |
/// \sa sectionReader(std::istream& is) |
|
| 2341 | 2402 |
inline SectionReader sectionReader(const char* fn) {
|
| ... | ... |
@@ -349,15 +349,13 @@ |
| 349 | 349 |
|
| 350 |
template <typename |
|
| 350 |
template <typename DGR> |
|
| 351 | 351 |
class DigraphWriter; |
| 352 | 352 |
|
| 353 |
template <typename Digraph> |
|
| 354 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 355 |
std::ostream& os = std::cout); |
|
| 356 |
template <typename Digraph> |
|
| 357 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 358 |
const std::string& fn); |
|
| 353 |
template <typename TDGR> |
|
| 354 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
| 355 |
std::ostream& os = std::cout); |
|
| 356 |
template <typename TDGR> |
|
| 357 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const std::string& fn); |
|
| 359 | 358 |
|
| 360 |
template <typename Digraph> |
|
| 361 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 362 |
|
|
| 359 |
template <typename TDGR> |
|
| 360 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn); |
|
| 363 | 361 |
|
| ... | ... |
@@ -383,3 +381,3 @@ |
| 383 | 381 |
///\code |
| 384 |
/// DigraphWriter< |
|
| 382 |
/// DigraphWriter<DGR>(digraph, std::cout). |
|
| 385 | 383 |
/// nodeMap("coordinates", coord_map).
|
| ... | ... |
@@ -408,3 +406,3 @@ |
| 408 | 406 |
/// output to the output of the first pass. |
| 409 |
template <typename |
|
| 407 |
template <typename DGR> |
|
| 410 | 408 |
class DigraphWriter {
|
| ... | ... |
@@ -412,4 +410,4 @@ |
| 412 | 410 |
|
| 413 |
typedef GR Digraph; |
|
| 414 |
TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); |
|
| 411 |
typedef DGR Digraph; |
|
| 412 |
TEMPLATE_DIGRAPH_TYPEDEFS(DGR); |
|
| 415 | 413 |
|
| ... | ... |
@@ -421,3 +419,3 @@ |
| 421 | 419 |
|
| 422 |
const |
|
| 420 |
const DGR& _digraph; |
|
| 423 | 421 |
|
| ... | ... |
@@ -453,3 +451,3 @@ |
| 453 | 451 |
/// output stream. |
| 454 |
DigraphWriter(const |
|
| 452 |
DigraphWriter(const DGR& digraph, std::ostream& os = std::cout) |
|
| 455 | 453 |
: _os(&os), local_os(false), _digraph(digraph), |
| ... | ... |
@@ -461,3 +459,3 @@ |
| 461 | 459 |
/// output file. |
| 462 |
DigraphWriter(const |
|
| 460 |
DigraphWriter(const DGR& digraph, const std::string& fn) |
|
| 463 | 461 |
: _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), |
| ... | ... |
@@ -474,3 +472,3 @@ |
| 474 | 472 |
/// output file. |
| 475 |
DigraphWriter(const |
|
| 473 |
DigraphWriter(const DGR& digraph, const char* fn) |
|
| 476 | 474 |
: _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), |
| ... | ... |
@@ -507,11 +505,11 @@ |
| 507 | 505 |
|
| 508 |
template <typename DGR> |
|
| 509 |
friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, |
|
| 510 |
std::ostream& os); |
|
| 511 |
template <typename DGR> |
|
| 512 |
friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, |
|
| 513 |
const std::string& fn); |
|
| 514 |
template <typename DGR> |
|
| 515 |
friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, |
|
| 516 |
|
|
| 506 |
template <typename TDGR> |
|
| 507 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
| 508 |
std::ostream& os); |
|
| 509 |
template <typename TDGR> |
|
| 510 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
| 511 |
const std::string& fn); |
|
| 512 |
template <typename TDGR> |
|
| 513 |
friend DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
| 514 |
const char *fn); |
|
| 517 | 515 |
|
| ... | ... |
@@ -726,4 +724,4 @@ |
| 726 | 724 |
if (label == 0) {
|
| 727 |
IdMap<Digraph, Node> id_map(_digraph); |
|
| 728 |
_writer_bits::MapLess<IdMap<Digraph, Node> > id_less(id_map); |
|
| 725 |
IdMap<DGR, Node> id_map(_digraph); |
|
| 726 |
_writer_bits::MapLess<IdMap<DGR, Node> > id_less(id_map); |
|
| 729 | 727 |
std::sort(nodes.begin(), nodes.end(), id_less); |
| ... | ... |
@@ -811,4 +809,4 @@ |
| 811 | 809 |
if (label == 0) {
|
| 812 |
IdMap<Digraph, Arc> id_map(_digraph); |
|
| 813 |
_writer_bits::MapLess<IdMap<Digraph, Arc> > id_less(id_map); |
|
| 810 |
IdMap<DGR, Arc> id_map(_digraph); |
|
| 811 |
_writer_bits::MapLess<IdMap<DGR, Arc> > id_less(id_map); |
|
| 814 | 812 |
std::sort(arcs.begin(), arcs.end(), id_less); |
| ... | ... |
@@ -917,10 +915,37 @@ |
| 917 | 915 |
|
| 916 |
/// \ingroup lemon_io |
|
| 917 |
/// |
|
| 918 | 918 |
/// \brief Return a \ref DigraphWriter class |
| 919 | 919 |
/// |
| 920 |
/// This function just returns a \ref DigraphWriter class. |
|
| 920 |
/// This function just returns a \ref DigraphWriter class. |
|
| 921 |
/// |
|
| 922 |
/// With this function a digraph can be write to a file or output |
|
| 923 |
/// stream in \ref lgf-format "LGF" format with several maps and |
|
| 924 |
/// attributes. For example, with the following code a network flow |
|
| 925 |
/// problem can be written to the standard output, i.e. a digraph |
|
| 926 |
/// with a \e capacity map on the arcs and \e source and \e target |
|
| 927 |
/// nodes: |
|
| 928 |
/// |
|
| 929 |
///\code |
|
| 930 |
///ListDigraph digraph; |
|
| 931 |
///ListDigraph::ArcMap<int> cap(digraph); |
|
| 932 |
///ListDigraph::Node src, trg; |
|
| 933 |
/// // Setting the capacity map and source and target nodes |
|
| 934 |
///digraphWriter(digraph, std::cout). |
|
| 935 |
/// arcMap("capacity", cap).
|
|
| 936 |
/// node("source", src).
|
|
| 937 |
/// node("target", trg).
|
|
| 938 |
/// run(); |
|
| 939 |
///\endcode |
|
| 940 |
/// |
|
| 941 |
/// For a complete documentation, please see the \ref DigraphWriter |
|
| 942 |
/// class documentation. |
|
| 943 |
/// \warning Don't forget to put the \ref DigraphWriter::run() "run()" |
|
| 944 |
/// to the end of the parameter list. |
|
| 921 | 945 |
/// \relates DigraphWriter |
| 922 |
template <typename Digraph> |
|
| 923 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 924 |
std::ostream& os) {
|
|
| 925 |
DigraphWriter<Digraph> tmp(digraph, os); |
|
| 946 |
/// \sa digraphWriter(const TDGR& digraph, const std::string& fn) |
|
| 947 |
/// \sa digraphWriter(const TDGR& digraph, const char* fn) |
|
| 948 |
template <typename TDGR> |
|
| 949 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, std::ostream& os) {
|
|
| 950 |
DigraphWriter<TDGR> tmp(digraph, os); |
|
| 926 | 951 |
return tmp; |
| ... | ... |
@@ -932,6 +957,7 @@ |
| 932 | 957 |
/// \relates DigraphWriter |
| 933 |
template <typename Digraph> |
|
| 934 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 935 |
const std::string& fn) {
|
|
| 936 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
| 958 |
/// \sa digraphWriter(const TDGR& digraph, std::ostream& os) |
|
| 959 |
template <typename TDGR> |
|
| 960 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, |
|
| 961 |
const std::string& fn) {
|
|
| 962 |
DigraphWriter<TDGR> tmp(digraph, fn); |
|
| 937 | 963 |
return tmp; |
| ... | ... |
@@ -943,6 +969,6 @@ |
| 943 | 969 |
/// \relates DigraphWriter |
| 944 |
template <typename Digraph> |
|
| 945 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
| 946 |
const char* fn) {
|
|
| 947 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
| 970 |
/// \sa digraphWriter(const TDGR& digraph, std::ostream& os) |
|
| 971 |
template <typename TDGR> |
|
| 972 |
DigraphWriter<TDGR> digraphWriter(const TDGR& digraph, const char* fn) {
|
|
| 973 |
DigraphWriter<TDGR> tmp(digraph, fn); |
|
| 948 | 974 |
return tmp; |
| ... | ... |
@@ -950,12 +976,11 @@ |
| 950 | 976 |
|
| 951 |
template <typename |
|
| 977 |
template <typename GR> |
|
| 952 | 978 |
class GraphWriter; |
| 953 | 979 |
|
| 954 |
template <typename Graph> |
|
| 955 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
| 956 |
std::ostream& os = std::cout); |
|
| 957 |
template <typename Graph> |
|
| 958 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); |
|
| 959 |
template <typename Graph> |
|
| 960 |
|
|
| 980 |
template <typename TGR> |
|
| 981 |
GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os = std::cout); |
|
| 982 |
template <typename TGR> |
|
| 983 |
GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn); |
|
| 984 |
template <typename TGR> |
|
| 985 |
GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn); |
|
| 961 | 986 |
|
| ... | ... |
@@ -981,3 +1006,3 @@ |
| 981 | 1006 |
typedef GR Graph; |
| 982 |
TEMPLATE_GRAPH_TYPEDEFS( |
|
| 1007 |
TEMPLATE_GRAPH_TYPEDEFS(GR); |
|
| 983 | 1008 |
|
| ... | ... |
@@ -989,3 +1014,3 @@ |
| 989 | 1014 |
|
| 990 |
const |
|
| 1015 |
const GR& _graph; |
|
| 991 | 1016 |
|
| ... | ... |
@@ -1021,3 +1046,3 @@ |
| 1021 | 1046 |
/// output stream. |
| 1022 |
GraphWriter(const |
|
| 1047 |
GraphWriter(const GR& graph, std::ostream& os = std::cout) |
|
| 1023 | 1048 |
: _os(&os), local_os(false), _graph(graph), |
| ... | ... |
@@ -1029,3 +1054,3 @@ |
| 1029 | 1054 |
/// output file. |
| 1030 |
GraphWriter(const |
|
| 1055 |
GraphWriter(const GR& graph, const std::string& fn) |
|
| 1031 | 1056 |
: _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
| ... | ... |
@@ -1042,3 +1067,3 @@ |
| 1042 | 1067 |
/// output file. |
| 1043 |
GraphWriter(const |
|
| 1068 |
GraphWriter(const GR& graph, const char* fn) |
|
| 1044 | 1069 |
: _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
| ... | ... |
@@ -1075,11 +1100,9 @@ |
| 1075 | 1100 |
|
| 1076 |
template <typename Graph> |
|
| 1077 |
friend GraphWriter<Graph> graphWriter(const Graph& graph, |
|
| 1078 |
std::ostream& os); |
|
| 1079 |
template <typename Graph> |
|
| 1080 |
friend GraphWriter<Graph> graphWriter(const Graph& graph, |
|
| 1081 |
const std::string& fn); |
|
| 1082 |
template <typename Graph> |
|
| 1083 |
friend GraphWriter<Graph> graphWriter(const Graph& graph, |
|
| 1084 |
|
|
| 1101 |
template <typename TGR> |
|
| 1102 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os); |
|
| 1103 |
template <typename TGR> |
|
| 1104 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, |
|
| 1105 |
const std::string& fn); |
|
| 1106 |
template <typename TGR> |
|
| 1107 |
friend GraphWriter<TGR> graphWriter(const TGR& graph, const char *fn); |
|
| 1085 | 1108 |
|
| ... | ... |
@@ -1170,6 +1193,6 @@ |
| 1170 | 1193 |
_writer_bits::MapStorageBase<Edge>* forward_storage = |
| 1171 |
new _writer_bits::GraphArcMapStorage< |
|
| 1194 |
new _writer_bits::GraphArcMapStorage<GR, true, Map>(_graph, map); |
|
| 1172 | 1195 |
_edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
|
| 1173 | 1196 |
_writer_bits::MapStorageBase<Edge>* backward_storage = |
| 1174 |
new _writer_bits::GraphArcMapStorage< |
|
| 1197 |
new _writer_bits::GraphArcMapStorage<GR, false, Map>(_graph, map); |
|
| 1175 | 1198 |
_edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
|
| ... | ... |
@@ -1187,3 +1210,3 @@ |
| 1187 | 1210 |
_writer_bits::MapStorageBase<Edge>* forward_storage = |
| 1188 |
new _writer_bits::GraphArcMapStorage< |
|
| 1211 |
new _writer_bits::GraphArcMapStorage<GR, true, Map, Converter> |
|
| 1189 | 1212 |
(_graph, map, converter); |
| ... | ... |
@@ -1191,3 +1214,3 @@ |
| 1191 | 1214 |
_writer_bits::MapStorageBase<Edge>* backward_storage = |
| 1192 |
new _writer_bits::GraphArcMapStorage< |
|
| 1215 |
new _writer_bits::GraphArcMapStorage<GR, false, Map, Converter> |
|
| 1193 | 1216 |
(_graph, map, converter); |
| ... | ... |
@@ -1249,3 +1272,3 @@ |
| 1249 | 1272 |
GraphWriter& arc(const std::string& caption, const Arc& arc) {
|
| 1250 |
typedef _writer_bits::GraphArcLookUpConverter< |
|
| 1273 |
typedef _writer_bits::GraphArcLookUpConverter<GR> Converter; |
|
| 1251 | 1274 |
Converter converter(_graph, _edge_index); |
| ... | ... |
@@ -1340,4 +1363,4 @@ |
| 1340 | 1363 |
if (label == 0) {
|
| 1341 |
IdMap<Graph, Node> id_map(_graph); |
|
| 1342 |
_writer_bits::MapLess<IdMap<Graph, Node> > id_less(id_map); |
|
| 1364 |
IdMap<GR, Node> id_map(_graph); |
|
| 1365 |
_writer_bits::MapLess<IdMap<GR, Node> > id_less(id_map); |
|
| 1343 | 1366 |
std::sort(nodes.begin(), nodes.end(), id_less); |
| ... | ... |
@@ -1425,4 +1448,4 @@ |
| 1425 | 1448 |
if (label == 0) {
|
| 1426 |
IdMap<Graph, Edge> id_map(_graph); |
|
| 1427 |
_writer_bits::MapLess<IdMap<Graph, Edge> > id_less(id_map); |
|
| 1449 |
IdMap<GR, Edge> id_map(_graph); |
|
| 1450 |
_writer_bits::MapLess<IdMap<GR, Edge> > id_less(id_map); |
|
| 1428 | 1451 |
std::sort(edges.begin(), edges.end(), id_less); |
| ... | ... |
@@ -1531,10 +1554,33 @@ |
| 1531 | 1554 |
|
| 1555 |
/// \ingroup lemon_io |
|
| 1556 |
/// |
|
| 1532 | 1557 |
/// \brief Return a \ref GraphWriter class |
| 1533 | 1558 |
/// |
| 1534 |
/// This function just returns a \ref GraphWriter class. |
|
| 1559 |
/// This function just returns a \ref GraphWriter class. |
|
| 1560 |
/// |
|
| 1561 |
/// With this function a graph can be write to a file or output |
|
| 1562 |
/// stream in \ref lgf-format "LGF" format with several maps and |
|
| 1563 |
/// attributes. For example, with the following code a weighted |
|
| 1564 |
/// matching problem can be written to the standard output, i.e. a |
|
| 1565 |
/// graph with a \e weight map on the edges: |
|
| 1566 |
/// |
|
| 1567 |
///\code |
|
| 1568 |
///ListGraph graph; |
|
| 1569 |
///ListGraph::EdgeMap<int> weight(graph); |
|
| 1570 |
/// // Setting the weight map |
|
| 1571 |
///graphWriter(graph, std::cout). |
|
| 1572 |
/// edgeMap("weight", weight).
|
|
| 1573 |
/// run(); |
|
| 1574 |
///\endcode |
|
| 1575 |
/// |
|
| 1576 |
/// For a complete documentation, please see the \ref GraphWriter |
|
| 1577 |
/// class documentation. |
|
| 1578 |
/// \warning Don't forget to put the \ref GraphWriter::run() "run()" |
|
| 1579 |
/// to the end of the parameter list. |
|
| 1535 | 1580 |
/// \relates GraphWriter |
| 1536 |
template <typename Graph> |
|
| 1537 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
| 1538 |
std::ostream& os) {
|
|
| 1539 |
GraphWriter<Graph> tmp(graph, os); |
|
| 1581 |
/// \sa graphWriter(const TGR& graph, const std::string& fn) |
|
| 1582 |
/// \sa graphWriter(const TGR& graph, const char* fn) |
|
| 1583 |
template <typename TGR> |
|
| 1584 |
GraphWriter<TGR> graphWriter(const TGR& graph, std::ostream& os) {
|
|
| 1585 |
GraphWriter<TGR> tmp(graph, os); |
|
| 1540 | 1586 |
return tmp; |
| ... | ... |
@@ -1546,5 +1592,6 @@ |
| 1546 | 1592 |
/// \relates GraphWriter |
| 1547 |
template <typename Graph> |
|
| 1548 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
|
|
| 1549 |
|
|
| 1593 |
/// \sa graphWriter(const TGR& graph, std::ostream& os) |
|
| 1594 |
template <typename TGR> |
|
| 1595 |
GraphWriter<TGR> graphWriter(const TGR& graph, const std::string& fn) {
|
|
| 1596 |
GraphWriter<TGR> tmp(graph, fn); |
|
| 1550 | 1597 |
return tmp; |
| ... | ... |
@@ -1556,5 +1603,6 @@ |
| 1556 | 1603 |
/// \relates GraphWriter |
| 1557 |
template <typename Graph> |
|
| 1558 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
|
|
| 1559 |
|
|
| 1604 |
/// \sa graphWriter(const TGR& graph, std::ostream& os) |
|
| 1605 |
template <typename TGR> |
|
| 1606 |
GraphWriter<TGR> graphWriter(const TGR& graph, const char* fn) {
|
|
| 1607 |
GraphWriter<TGR> tmp(graph, fn); |
|
| 1560 | 1608 |
return tmp; |
| ... | ... |
@@ -1748,2 +1796,4 @@ |
| 1748 | 1796 |
|
| 1797 |
/// \ingroup lemon_io |
|
| 1798 |
/// |
|
| 1749 | 1799 |
/// \brief Return a \ref SectionWriter class |
| ... | ... |
@@ -1751,3 +1801,9 @@ |
| 1751 | 1801 |
/// This function just returns a \ref SectionWriter class. |
| 1802 |
/// |
|
| 1803 |
/// Please see SectionWriter documentation about the custom section |
|
| 1804 |
/// output. |
|
| 1805 |
/// |
|
| 1752 | 1806 |
/// \relates SectionWriter |
| 1807 |
/// \sa sectionWriter(const std::string& fn) |
|
| 1808 |
/// \sa sectionWriter(const char *fn) |
|
| 1753 | 1809 |
inline SectionWriter sectionWriter(std::ostream& os) {
|
| ... | ... |
@@ -1761,2 +1817,3 @@ |
| 1761 | 1817 |
/// \relates SectionWriter |
| 1818 |
/// \sa sectionWriter(std::ostream& os) |
|
| 1762 | 1819 |
inline SectionWriter sectionWriter(const std::string& fn) {
|
| ... | ... |
@@ -1770,2 +1827,3 @@ |
| 1770 | 1827 |
/// \relates SectionWriter |
| 1828 |
/// \sa sectionWriter(std::ostream& os) |
|
| 1771 | 1829 |
inline SectionWriter sectionWriter(const char* fn) {
|
0 comments (0 inline)