All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
List of all members | Public Member Functions
DigraphWriter< DGR > Class Template Reference

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();

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 >
DigraphWriternodeMap (const std::string &caption, const Map &map)
 Node map writing rule.
 
template<typename Map , typename Converter >
DigraphWriternodeMap (const std::string &caption, const Map &map, const Converter &converter=Converter())
 Node map writing rule.
 
template<typename Map >
DigraphWriterarcMap (const std::string &caption, const Map &map)
 Arc map writing rule.
 
template<typename Map , typename Converter >
DigraphWriterarcMap (const std::string &caption, const Map &map, const Converter &converter=Converter())
 Arc map writing rule.
 
template<typename Value >
DigraphWriterattribute (const std::string &caption, const Value &value)
 Attribute writing rule.
 
template<typename Value , typename Converter >
DigraphWriterattribute (const std::string &caption, const Value &value, const Converter &converter=Converter())
 Attribute writing rule.
 
DigraphWriternode (const std::string &caption, const Node &node)
 Node writing rule.
 
DigraphWriterarc (const std::string &caption, const Arc &arc)
 Arc writing rule.
 
Section Captions
DigraphWriternodes (const std::string &caption)
 
DigraphWriterarcs (const std::string &caption)
 
DigraphWriterattributes (const std::string &caption)
 
Skipping Section
DigraphWriterskipNodes ()
 Skip writing the node set.
 
DigraphWriterskipArcs ()
 Skip writing arc set.
 
Execution of the Writer
void run ()
 Start the batch processing.
 
std::ostream & ostream ()
 

Constructor & Destructor Documentation

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

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

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

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

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

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

Member Function Documentation

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

Add a node map writing rule to the writer.

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.

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

Add an arc map writing rule to the writer.

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.

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

Add an attribute writing rule to the writer.

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.

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

Add a node writing rule to the writer.

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

Add an arc writing rule to writer.

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

Add an additional caption to the @nodes section.

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

Add an additional caption to the @arcs section.

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

Add an additional caption to the @attributes section.

DigraphWriter& skipNodes ( )
inline

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

DigraphWriter& skipArcs ( )
inline

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

void run ( )
inline

This function starts the batch processing.

std::ostream& ostream ( )
inline

Give back the stream of the writer.