GraphWriter Class Template Reference
[Input Output]

#include <lemon/graph_writer.h>

List of all members.


Detailed Description

template<typename _Graph, typename _WriterTraits = DefaultWriterTraits>
class lemon::GraphWriter< _Graph, _WriterTraits >

The GraphWriter class provides the graph output. Before you read this documentation it might be useful to read the general description of Graph Input-Output.

If you don't need very sophisticated behaviour then you can use the versions of the public function writeGraph() to output a graph (or a max flow instance etc).

To write a graph you should first give writing commands to the writer. You can declare write commands as NodeMap or EdgeMap writing and labeled Node and Edge writing.

      GraphWriter<ListGraph> writer(std::cout, graph);

The writeNodeMap() function declares a NodeMap writing command in the GraphWriter. You should give as parameter the name of the map and the map object. The NodeMap writing command with name "label" should write a unique map because it is regarded as label map (such a map is essential if the graph has edges).

      IdMap<ListGraph, Node> nodeLabelMap;
      writer.writeNodeMap("label", nodeLabelMap);
     
      writer.writeNodeMap("coords", coords);
      writer.writeNodeMap("color", colorMap);

With the writeEdgeMap() member function you can give an edge map writing command similar to the NodeMaps.

      DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > 
        edgeDescMap(graph);
      writer.writeEdgeMap("descriptor", edgeDescMap);
     
      writer.writeEdgeMap("weight", weightMap);
      writer.writeEdgeMap("label", labelMap);

With writeNode() and writeEdge() functions you can point out Nodes and Edges in the graph. For example, you can write out the source and target of a maximum flow instance.

      writer.writeNode("source", sourceNode);
      writer.writeNode("target", targetNode);
     
      writer.writeEdge("observed", edge);

After you give all write commands you must call the run() member function, which executes all the writing commands.

      writer.run();

See also:
DefaultWriterTraits

QuotedStringWriter

IdMap

DescriptorMap

GraphReader

Graph Input-Output

Author:
Balazs Dezso


Public Member Functions

 GraphWriter (std::ostream &_os, const Graph &_graph)
 Construct a new GraphWriter.
 GraphWriter (const std::string &_filename, const Graph &_graph)
 Construct a new GraphWriter.
 GraphWriter (LemonWriter &_writer, const Graph &_graph)
 Construct a new GraphWriter.
 ~GraphWriter ()
 Destruct the graph writer.
template<typename Map>
GraphWriterwriteNodeMap (std::string name, const Map &map)
 This function issues a new node map writing command to the writer.
template<typename Writer, typename Map>
GraphWriterwriteNodeMap (std::string name, const Map &map, const Writer &writer=Writer())
 This function issues a new node map writing command to the writer.
template<typename Map>
GraphWriterwriteEdgeMap (std::string name, const Map &map)
 This function issues a new edge map writing command to the writer.
template<typename Writer, typename Map>
GraphWriterwriteEdgeMap (std::string name, const Map &map, const Writer &writer=Writer())
 This function issues a new edge map writing command to the writer.
GraphWriterwriteNode (std::string name, const Node &node)
 Issue a new labeled node writing command to the writer.
GraphWriterwriteEdge (std::string name, const Edge &edge)
 Issue a new labeled edge writing command to the writer.
template<typename Value>
GraphWriterwriteAttribute (std::string name, const Value &value)
 Issue a new attribute writing command.
template<typename Writer, typename Value>
GraphWriterwriteAttribute (std::string name, const Value &value, const Writer &writer)
 Issue a new attribute writing command.
 operator LemonWriter & ()
 Conversion operator to LemonWriter.
void run ()
 Executes the writing commands.
void writeLabel (std::ostream &os, const Node &item) const
 Write the label of the given node.
void writeLabel (std::ostream &os, const Edge &item) const
 Write the label of the given edge.


Constructor & Destructor Documentation

GraphWriter std::ostream &  _os,
const Graph &  _graph
[inline]
 

This function constructs a new GraphWriter to write the given graph to the given stream.

GraphWriter const std::string &  _filename,
const Graph &  _graph
[inline]
 

This function constructs a new GraphWriter to write the given graph to the given file.

GraphWriter LemonWriter _writer,
const Graph &  _graph
[inline]
 

This function constructs a new GraphWriter to write the given graph to the given LemonReader.

~GraphWriter  )  [inline]
 

This function destructs the graph writer.


Member Function Documentation

GraphWriter& writeNode std::string  name,
const Node &  node
[inline]
 

This function issues a new labeled node writing command to the writer.

GraphWriter& writeEdge std::string  name,
const Edge &  edge
[inline]
 

This function issues a new labeled edge writing command to the writer.

GraphWriter& writeAttribute std::string  name,
const Value &  value
[inline]
 

This function issues a new attribute writing command to the writer.

GraphWriter& writeAttribute std::string  name,
const Value &  value,
const Writer &  writer
[inline]
 

This function issues a new attribute writing command to the writer.

operator LemonWriter &  )  [inline]
 

Conversion operator to LemonWriter. It makes possible to access the encapsulated LemonWriter, this way you can attach to this writer new instances of LemonWriter::SectionWriter. For more details see the Background of Reading and Writing.

void run  )  [inline]
 

Executes the writing commands.

void writeLabel std::ostream &  os,
const Node &  item
const [inline]
 

It writes the label of the given node. If there was written an "label" named node map then it will write the map value belonging to the node.

void writeLabel std::ostream &  os,
const Edge &  item
const [inline]
 

It writes the label of the given edge. If there was written an "label" named edge map then it will write the map value belonging to the edge.


The documentation for this class was generated from the following file:
Generated on Fri Feb 3 18:41:38 2006 for LEMON by  doxygen 1.4.6