DigraphWriter Class Template Reference
[LEMON Input-Output]


Detailed Description

template<typename _Digraph>
class lemon::DigraphWriter< _Digraph >

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<Digraph>(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>

List of all members.

Public Member Functions

 DigraphWriter (const Digraph &digraph, std::ostream &os=std::cout)
 Constructor.
 DigraphWriter (const Digraph &digraph, const std::string &fn)
 Constructor.
 DigraphWriter (const Digraph &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)
 Add an additional caption to the @nodes section.
DigraphWriterarcs (const std::string &caption)
 Add an additional caption to the @arcs section.
DigraphWriterattributes (const std::string &caption)
 Add an additional caption to the @attributes section.
Skipping section
DigraphWriterskipNodes ()
 Skip writing the node set.
DigraphWriterskipArcs ()
 Skip writing arc set.
Execution of the writer
void run ()
 Start the batch processing.
std::ostreamostream ()
 Give back the stream of the writer.

Friends

DigraphWriter< Digraph > digraphWriter (const Digraph &digraph, std::ostream &os)
 Return a DigraphWriter class.
DigraphWriter< Digraph > digraphWriter (const Digraph &digraph, const std::string &fn)
 Return a DigraphWriter class.
DigraphWriter< Digraph > digraphWriter (const Digraph &digraph, const char *fn)
 Return a DigraphWriter class.


Constructor & Destructor Documentation

DigraphWriter ( const Digraph &  digraph,
std::ostream os = std::cout 
) [inline]

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

DigraphWriter ( const Digraph &  digraph,
const std::string fn 
) [inline]

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

DigraphWriter ( const Digraph &  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.


Friends And Related Function Documentation

DigraphWriter< Digraph > digraphWriter ( const Digraph &  digraph,
std::ostream os = std::cout 
) [friend]

This function just returns a DigraphWriter class.

DigraphWriter< Digraph > digraphWriter ( const Digraph &  digraph,
const std::string fn 
) [friend]

This function just returns a DigraphWriter class.

DigraphWriter< Digraph > digraphWriter ( const Digraph &  digraph,
const char *  fn 
) [friend]

This function just returns a DigraphWriter class.


The documentation for this class was generated from the following file:

Generated on Sun Oct 12 20:09:48 2008 for LEMON by  doxygen 1.5.7.1