DigraphWriter
Declared in lemon/lgf_writer.h, in the group LEMON Graph Format; the same class on the Doxygen site.
-
template< typename DGR >
class DigraphWriter LGF writer for directed graphs
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 thenodeMap()orarcMap()members. An optional converter parameter can also be added as a standard functor converting from the value type of the map tostd::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. Theattribute(),node()andarc()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()orattributes()functions.The
skipNodes()andskipArcs()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 theostream()function, hence the second pass can append its output to the output of the first pass.Warning
The values given to the node, arc, edge and attribute writing rules are kept by reference and read by run(), hence they have to exist until then: a temporary passed to a rule is destroyed at the end of the expression that passes it.
Writing Rules
-
template< typename Map >
inline DigraphWriter & nodeMap( - const std::string & caption,
- const Map & map
Node map writing rule.
Add a node map writing rule to the writer.
-
template< typename Map , typename Converter >
inline DigraphWriter & nodeMap(
) Node map writing rule.
Add a node map writing rule with specialized converter to the writer.
-
template< typename Map >
inline DigraphWriter & arcMap( - const std::string & caption,
- const Map & map
Arc map writing rule.
Add an arc map writing rule to the writer.
-
template< typename Map , typename Converter >
inline DigraphWriter & arcMap(
) Arc map writing rule.
Add an arc map writing rule with specialized converter to the writer.
-
template< typename Value >
inline DigraphWriter & attribute( - const std::string & caption,
- const Value & value
Attribute writing rule.
Add an attribute writing rule to the writer.
-
template< typename Value , typename Converter >
inline DigraphWriter & attribute(
) Attribute writing rule.
Add an attribute writing rule with specialized converter to the writer.
-
inline DigraphWriter & node( const std::string & caption , const Node & node )
Node writing rule.
Add a node writing rule to the writer.
-
inline DigraphWriter & arc( const std::string & caption , const Arc & arc )
Arc writing rule.
Add an arc writing rule to writer.
Section Captions
-
inline DigraphWriter & nodes( const std::string & caption )
Add an additional caption to the
@nodessection.
-
inline DigraphWriter & arcs( const std::string & caption )
Add an additional caption to the
@arcssection.
-
inline DigraphWriter & attributes( const std::string & caption )
Add an additional caption to the
@attributessection.
Skipping Section
-
inline DigraphWriter & skipNodes()
Skip writing the node set.
The
@nodessection will not be written to the stream.
-
inline DigraphWriter & skipArcs()
Skip writing arc set.
The
@arcssection will not be written to the stream.
Execution of the Writer
-
inline void run()
Start the batch processing.
This function starts the batch processing.
-
inline std::ostream & ostream()
Give back the stream of the writer.
Public Functions
-
inline DigraphWriter( const DGR & digraph , std::ostream & os = std::cout )
Constructor.
Construct a directed graph writer, which writes to the given output stream.
-
inline DigraphWriter( const DGR & digraph , const std::string & fn )
Constructor.
Construct a directed graph writer, which writes to the given output file.
-
inline DigraphWriter( const DGR & digraph , const char * fn )
Constructor.
Construct a directed graph writer, which writes to the given output file.
-
inline ~DigraphWriter()
Destructor.
-
template< typename TDGR >
DigraphWriter< TDGR > digraphWriter( - const TDGR & digraph,
- const std::string & fn
Return a DigraphWriter class.
This function just returns a DigraphWriter class.
See also
digraphWriter( const TDGR & digraph , std::ostream & os )
-
template< typename TDGR >
DigraphWriter< TDGR > digraphWriter( - const TDGR & digraph,
- const char * fn
Return a DigraphWriter class.
This function just returns a DigraphWriter class.
See also
digraphWriter( const TDGR & digraph , std::ostream & os )
-
template< typename Map >