Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UndirGraphWriter Class Template Reference
[Input Output]

#include <lemon/graph_writer.h>

List of all members.


Detailed Description

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

The UndirGraphWriter class provides the undir graph output. To write a graph you should first give writing commands to the writer. You can declare write command as NodeMap, EdgeMap or UndirEdgeMap writing and labeled Node, Edge or UndirEdge writing.

      UndirGraphWriter<UndirListGraph> writer(std::cout, graph);

The writeNodeMap() function declares a NodeMap writing command in the UndirGraphWriter. You should give as parameter the name of the map and the map object. The NodeMap writing command with name "id" should write a unique map because it is regarded as ID map.

      IdMap<UndirListGraph, Node> nodeIdMap;
      writer.writeNodeMap("id", nodeIdMap);
     
      writer.writeNodeMap("coords", coords);
      writer.writeNodeMap("color", colorMap);

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

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

The EdgeMap handling is just a syntactical sugar. It writes two undirected edge map with '+' and '-' prefix in the name.

      writer.writeEdgeMap("capacity", capacityMap);

With writeNode() and writeUndirEdge() functions you can designate nodes and undirected edges in the graph. For example, you can write out the source and target of the graph.

      writer.writeNode("source", sourceNode);
      writer.writeNode("target", targetNode);
     
      writer.writeUndirEdge("observed", undirEdge);

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

GraphWriter

Graph Input-Output

Author:
Balazs Dezso


Public Member Functions

 UndirGraphWriter (std::ostream &_os, const Graph &_graph)
 Construct a new UndirGraphWriter.
 UndirGraphWriter (const std::string &_filename, const Graph &_graph)
 Construct a new UndirGraphWriter.
 UndirGraphWriter (LemonWriter &_writer, const Graph &_graph)
 Construct a new UndirGraphWriter.
 ~UndirGraphWriter ()
 Destruct the graph writer.
template<typename Map>
UndirGraphWriterwriteNodeMap (std::string name, const Map &map)
 This function issues a new node map writing command to the writer.
template<typename Writer, typename Map>
UndirGraphWriterwriteNodeMap (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>
UndirGraphWriterwriteEdgeMap (std::string name, const Map &map)
 This function issues a new edge map writing command to the writer.
template<typename Writer, typename Map>
UndirGraphWriterwriteEdgeMap (std::string name, const Map &map, const Writer &writer=Writer())
 This function issues a new edge map writing command to the writer.
template<typename Map>
UndirGraphWriterwriteUndirEdgeMap (std::string name, const Map &map)
 Issue a new undirected edge map writing command to the writer.
template<typename Writer, typename Map>
UndirGraphWriterwriteUndirEdgeMap (std::string name, const Map &map, const Writer &writer=Writer())
 Issue a new undirected edge map writing command to the writer.
UndirGraphWriterwriteNode (std::string name, const Node &node)
 Issue a new labeled node writer to the writer.
UndirGraphWriterwriteEdge (std::string name, const Edge &edge)
 Issue a new labeled edge writer to the writer.
UndirGraphWriterwriteUndirEdge (std::string name, const UndirEdge &edge)
 Issue a new labeled undirected edge writing command to the writer.
template<typename Value>
UndirGraphWriterwriteAttribute (std::string name, const Value &value)
 Issue a new attribute writing command.
template<typename Writer, typename Value>
UndirGraphWriterwriteAttribute (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 writeId (std::ostream &os, const Node &item) const
 Write the id of the given node.
void writeId (std::ostream &os, const Edge &item) const
 Write the id of the given edge.
void writeId (std::ostream &os, const UndirEdge &item) const
 Write the id of the given undirected edge.


Constructor & Destructor Documentation

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

Construct a new UndirGraphWriter. It writes the given graph to the given stream.

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

Construct a new UndirGraphWriter. It writes the given graph to the given file.

UndirGraphWriter LemonWriter _writer,
const Graph &  _graph
[inline]
 

Construct a new UndirGraphWriter. It writes the given graph to given LemonReader.

~UndirGraphWriter  )  [inline]
 

Destruct the graph writer.


Member Function Documentation

UndirGraphWriter& writeUndirEdgeMap std::string  name,
const Map &  map
[inline]
 

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

UndirGraphWriter& writeUndirEdgeMap std::string  name,
const Map &  map,
const Writer &  writer = Writer()
[inline]
 

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

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

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

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

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

UndirGraphWriter& writeUndirEdge std::string  name,
const UndirEdge &  edge
[inline]
 

Issue a new labeled undirected edge writing command to the writer.

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

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

UndirGraphWriter& 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.

void run  )  [inline]
 

Executes the writing commands.

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

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

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

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

void writeId std::ostream os,
const UndirEdge &  item
const [inline]
 

It writes the id of the given undirected edge. If there was written an "id" 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 Sat Aug 27 14:15:37 2005 for LEMON by  doxygen 1.4.4