template<typename DGR>
class lemon::DigraphReader< DGR >
This utility reads an LGF file.
The reading method does a batch processing. The user creates a reader object, then various reading rules can be added to the reader, and eventually the reading is executed with the run()
member function. A map reading rule can be added to the reader with the nodeMap()
or arcMap()
members. An optional converter parameter can also be added as a standard functor converting from std::string
to the value type of the map. If it is set, it will determine how the tokens in the file should be converted to the value type of the map. If the functor is not set, then a default conversion will be used. One map can be read into multiple map objects at the same time. The attribute()
, node()
and arc()
functions are used to add attribute reading rules.
DigraphReader<DGR>(digraph, std::cin).
By default the reader uses the first section in the file of the proper type. If a section has an optional name, then it can be selected for reading by giving an optional name parameter to the nodes()
, arcs()
or attributes()
functions.
The useNodes()
and useArcs()
functions are used to tell the reader that the nodes or arcs should not be constructed (added to the graph) during the reading, but instead the label map of the items are given as a parameter of these functions. An application of these functions is multipass reading, which is important if two @arcs
sections must be read from the file. In this case the first phase would read the node set and one of the arc sets, while the second phase would read the second arc set into an ArcSet class (SmartArcSet
or ListArcSet
). The previously read label node map should be passed to the useNodes()
functions. Another application of multipass reading when paths are given as a node map or an arc map. It is impossible to read this in a single pass, because the arcs are not constructed when the node maps are read.
|
| DigraphReader (DGR &digraph, std::istream &is=std::cin) |
| Constructor.
|
|
| DigraphReader (DGR &digraph, const std::string &fn) |
| Constructor.
|
|
| DigraphReader (DGR &digraph, const char *fn) |
| Constructor.
|
|
| ~DigraphReader () |
| Destructor.
|
|
|
template<typename Map > |
DigraphReader & | nodeMap (const std::string &caption, Map &map) |
| Node map reading rule.
|
|
template<typename Map , typename Converter > |
DigraphReader & | nodeMap (const std::string &caption, Map &map, const Converter &converter=Converter()) |
| Node map reading rule.
|
|
template<typename Map > |
DigraphReader & | arcMap (const std::string &caption, Map &map) |
| Arc map reading rule.
|
|
template<typename Map , typename Converter > |
DigraphReader & | arcMap (const std::string &caption, Map &map, const Converter &converter=Converter()) |
| Arc map reading rule.
|
|
template<typename Value > |
DigraphReader & | attribute (const std::string &caption, Value &value) |
| Attribute reading rule.
|
|
template<typename Value , typename Converter > |
DigraphReader & | attribute (const std::string &caption, Value &value, const Converter &converter=Converter()) |
| Attribute reading rule.
|
|
DigraphReader & | node (const std::string &caption, Node &node) |
| Node reading rule.
|
|
DigraphReader & | arc (const std::string &caption, Arc &arc) |
| Arc reading rule.
|
|
|
DigraphReader & | nodes (const std::string &caption) |
| Set @nodes section to be read.
|
|
DigraphReader & | arcs (const std::string &caption) |
| Set @arcs section to be read.
|
|
DigraphReader & | attributes (const std::string &caption) |
| Set @attributes section to be read.
|
|
|
template<typename Map > |
DigraphReader & | useNodes (const Map &map) |
| Use previously constructed node set.
|
|
template<typename Map , typename Converter > |
DigraphReader & | useNodes (const Map &map, const Converter &converter=Converter()) |
| Use previously constructed node set.
|
|
template<typename Map > |
DigraphReader & | useArcs (const Map &map) |
| Use previously constructed arc set.
|
|
template<typename Map , typename Converter > |
DigraphReader & | useArcs (const Map &map, const Converter &converter=Converter()) |
| Use previously constructed arc set.
|
|
DigraphReader & | skipNodes () |
| Skips the reading of node section.
|
|
DigraphReader & | skipArcs () |
| Skips the reading of arc section.
|
|
|
void | run () |
| Start the batch processing.
|
|