template<typename DGR>
class lemon::DigraphWriter< DGR >
This utility writes an LGF file.
The writing method does a batch processing. The user creates a writer object, then various writing rules can be added to the writer, and eventually the writing is executed with the run()
member function. A map writing rule can be added to the writer with the nodeMap()
or arcMap()
members. An optional converter parameter can also be added as a standard functor converting from the value type of the map to std::string
. If it is set, it will determine how the value type of the map is written to the output stream. If the functor is not set, then a default conversion will be used. The attribute()
, node()
and arc()
functions are used to add attribute writing rules.
* DigraphWriter<DGR>(digraph, std::cout).
*
nodeMap(
"coordinates", coord_map).
*
arcMap(
"capacity", cap_map).
*
By default, the writer does not write additional captions to the sections, but they can be give as an optional parameter of the nodes()
, arcs()
or attributes()
functions.
The skipNodes()
and skipArcs()
functions forbid the writing of the sections. If two arc sections should be written to the output, it can be done in two passes, the first pass writes the node section and the first arc section, then the second pass skips the node section and writes just the arc section to the stream. The output stream can be retrieved with the ostream()
function, hence the second pass can append its output to the output of the first pass.
|
| DigraphWriter (const DGR &digraph, std::ostream &os=std::cout) |
| Constructor. More...
|
|
| DigraphWriter (const DGR &digraph, const std::string &fn) |
| Constructor. More...
|
|
| DigraphWriter (const DGR &digraph, const char *fn) |
| Constructor. More...
|
|
| ~DigraphWriter () |
| Destructor.
|
|
|
template<typename Map > |
DigraphWriter & | nodeMap (const std::string &caption, const Map &map) |
| Node map writing rule. More...
|
|
template<typename Map , typename Converter > |
DigraphWriter & | nodeMap (const std::string &caption, const Map &map, const Converter &converter=Converter()) |
| Node map writing rule. More...
|
|
template<typename Map > |
DigraphWriter & | arcMap (const std::string &caption, const Map &map) |
| Arc map writing rule. More...
|
|
template<typename Map , typename Converter > |
DigraphWriter & | arcMap (const std::string &caption, const Map &map, const Converter &converter=Converter()) |
| Arc map writing rule. More...
|
|
template<typename Value > |
DigraphWriter & | attribute (const std::string &caption, const Value &value) |
| Attribute writing rule. More...
|
|
template<typename Value , typename Converter > |
DigraphWriter & | attribute (const std::string &caption, const Value &value, const Converter &converter=Converter()) |
| Attribute writing rule. More...
|
|
DigraphWriter & | node (const std::string &caption, const Node &node) |
| Node writing rule. More...
|
|
DigraphWriter & | arc (const std::string &caption, const Arc &arc) |
| Arc writing rule. More...
|
|
|
DigraphWriter & | nodes (const std::string &caption) |
| Add an additional caption to the @nodes section. More...
|
|
DigraphWriter & | arcs (const std::string &caption) |
| Add an additional caption to the @arcs section. More...
|
|
DigraphWriter & | attributes (const std::string &caption) |
| Add an additional caption to the @attributes section. More...
|
|
|
DigraphWriter & | skipNodes () |
| Skip writing the node set. More...
|
|
DigraphWriter & | skipArcs () |
| Skip writing arc set. More...
|
|
|
void | run () |
| Start the batch processing. More...
|
|
std::ostream & | ostream () |
| Give back the stream of the writer. More...
|
|