Loading...
Searching...
No Matches
DigraphWriter< DGR > Class Template Reference
Input-Output » LEMON Graph Format

## Detailed Description

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).
nodeMap("size", size).
nodeMap("title", title).
arcMap("capacity", cap_map).
node("source", src).
node("target", trg).
attribute("caption", caption).
run();
lemon::DigraphWriter::run
void run()
Start the batch processing.
Definition lgf_writer.h:921
lemon::DigraphWriter::attribute
DigraphWriter & attribute(const std::string &caption, const Value &value)
Attribute writing rule.
Definition lgf_writer.h:627
lemon::DigraphWriter::DigraphWriter
DigraphWriter(const DGR &digraph, std::ostream &os=std::cout)
Constructor.
Definition lgf_writer.h:481
lemon::DigraphWriter::node
DigraphWriter & node(const std::string &caption, const Node &node)
Node writing rule.
Definition lgf_writer.h:650
lemon::DigraphWriter::arcMap
DigraphWriter & arcMap(const std::string &caption, const Map &map)
Arc map writing rule.
Definition lgf_writer.h:601
lemon::DigraphWriter::nodeMap
DigraphWriter & nodeMap(const std::string &caption, const Map &map)
Node map writing rule.
Definition lgf_writer.h:575

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.

`#include <lemon/lgf_writer.h>`

## Public Member Functions

| DigraphWriter (const DGR &digraph, std::ostream &os=std::cout)
| Constructor.
| DigraphWriter (const DGR &digraph, const std::string &fn)
| Constructor.
| DigraphWriter (const DGR &digraph, const char *fn)
| Constructor.
| ~DigraphWriter ()
| Destructor.
Writing Rules
template<typename Map>
DigraphWriter & | nodeMap (const std::string &caption, const Map &map)
| Node map writing rule.
template<typename Map, typename Converter>
DigraphWriter & | nodeMap (const std::string &caption, const Map &map, const Converter &converter=Converter())
| Node map writing rule.
template<typename Map>
DigraphWriter & | arcMap (const std::string &caption, const Map &map)
| Arc map writing rule.
template<typename Map, typename Converter>
DigraphWriter & | arcMap (const std::string &caption, const Map &map, const Converter &converter=Converter())
| Arc map writing rule.
template<typename Value>
DigraphWriter & | attribute (const std::string &caption, const Value &value)
| Attribute writing rule.
template<typename Value, typename Converter>
DigraphWriter & | attribute (const std::string &caption, const Value &value, const Converter &converter=Converter())
| Attribute writing rule.
DigraphWriter & | node (const std::string &caption, const Node &node)
| Node writing rule.
DigraphWriter & | arc (const std::string &caption, const Arc &arc)
| Arc writing rule.
Section Captions
DigraphWriter & | nodes (const std::string &caption)
| Add an additional caption to the `@nodes` section.
DigraphWriter & | arcs (const std::string &caption)
| Add an additional caption to the `@arcs` section.
DigraphWriter & | attributes (const std::string &caption)
| Add an additional caption to the `@attributes` section.
Skipping Section
DigraphWriter & | skipNodes ()
| Skip writing the node set.
DigraphWriter & | skipArcs ()
| Skip writing arc set.
Execution of the Writer
void | run ()
| Start the batch processing.
std::ostream & | ostream ()
| Give back the stream of the writer.

## Related Symbols

(Note that these are not member symbols.)
template<typename TDGR>
DigraphWriter< TDGR > | digraphWriter (const TDGR &digraph, std::ostream &os)
| Return a DigraphWriter class.
template<typename TDGR>
DigraphWriter< TDGR > | digraphWriter (const TDGR &digraph, const std::string &fn)
| Return a DigraphWriter class.
template<typename TDGR>
DigraphWriter< TDGR > | digraphWriter (const TDGR &digraph, const char *fn)
| Return a DigraphWriter class.

## Constructor & Destructor Documentation

## DigraphWriter() [1/3]

template<typename DGR>

DigraphWriter | ( | const DGR & | digraph,
|  | std::ostream & | os = std::cout )

inline

Construct a directed graph writer, which writes to the given output stream.

## DigraphWriter() [2/3]

template<typename DGR>

DigraphWriter | ( | const DGR & | digraph,
|  | const std::string & | fn )

inline

Construct a directed graph writer, which writes to the given output file.

## DigraphWriter() [3/3]

template<typename DGR>

DigraphWriter | ( | const DGR & | digraph,
|  | const char * | fn )

inline

Construct a directed graph writer, which writes to the given output file.

## Member Function Documentation

## nodeMap() [1/2]

template<typename DGR>
template<typename Map>

DigraphWriter & nodeMap | ( | const std::string & | caption,
|  | const Map & | map )

inline

Add a node map writing rule to the writer.

## nodeMap() [2/2]

template<typename DGR>
template<typename Map, typename Converter>

DigraphWriter & nodeMap | ( | const std::string & | caption,
|  | const Map & | map,
|  | const Converter & | converter = Converter() )

inline

Add a node map writing rule with specialized converter to the writer.

## arcMap() [1/2]

template<typename DGR>
template<typename Map>

DigraphWriter & arcMap | ( | const std::string & | caption,
|  | const Map & | map )

inline

Add an arc map writing rule to the writer.

## arcMap() [2/2]

template<typename DGR>
template<typename Map, typename Converter>

DigraphWriter & arcMap | ( | const std::string & | caption,
|  | const Map & | map,
|  | const Converter & | converter = Converter() )

inline

Add an arc map writing rule with specialized converter to the writer.

## attribute() [1/2]

template<typename DGR>
template<typename Value>

DigraphWriter & attribute | ( | const std::string & | caption,
|  | const Value & | value )

inline

Add an attribute writing rule to the writer.

## attribute() [2/2]

template<typename DGR>
template<typename Value, typename Converter>

DigraphWriter & attribute | ( | const std::string & | caption,
|  | const Value & | value,
|  | const Converter & | converter = Converter() )

inline

Add an attribute writing rule with specialized converter to the writer.

## node()

template<typename DGR>

DigraphWriter & node | ( | const std::string & | caption,
|  | const Node & | node )

inline

Add a node writing rule to the writer.

## arc()

template<typename DGR>

DigraphWriter & arc | ( | const std::string & | caption,
|  | const Arc & | arc )

inline

Add an arc writing rule to writer.

## nodes()

template<typename DGR>

DigraphWriter & nodes | ( | const std::string & | caption | ) |

inline

Add an additional caption to the `@nodes` section.

## arcs()

template<typename DGR>

DigraphWriter & arcs | ( | const std::string & | caption | ) |

inline

Add an additional caption to the `@arcs` section.

## attributes()

template<typename DGR>

DigraphWriter & attributes | ( | const std::string & | caption | ) |

inline

Add an additional caption to the `@attributes` section.

## skipNodes()

template<typename DGR>

DigraphWriter & skipNodes | ( |  | ) |

inline

The `@nodes` section will not be written to the stream.

## skipArcs()

template<typename DGR>

DigraphWriter & skipArcs | ( |  | ) |

inline

The `@arcs` section will not be written to the stream.

## run()

template<typename DGR>

void run | ( |  | ) |

inline

This function starts the batch processing.

## ostream()

template<typename DGR>

std::ostream & ostream | ( |  | ) |

inline

Give back the stream of the writer.

## Friends And Related Symbol Documentation

## digraphWriter() [1/2]

template<typename TDGR>

DigraphWriter< TDGR > digraphWriter | ( | const TDGR & | digraph,
|  | const std::string & | fn )

related

This function just returns a DigraphWriter class.

See also
  digraphWriter(const TDGR& digraph, std::ostream& os)

## digraphWriter() [2/2]

template<typename TDGR>

DigraphWriter< TDGR > digraphWriter | ( | const TDGR & | digraph,
|  | const char * | fn )

related

This function just returns a DigraphWriter class.

See also
  digraphWriter(const TDGR& digraph, std::ostream& os)