BpUGraphWriter< _Graph, _WriterTraits > Class Template Reference
[Lemon Input-Output]


Detailed Description

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

The BpUGraphWriter class provides the ugraph output. To write a graph you should first give writing commands to the writer. You can declare write command as NodeMap, EdgeMap or UEdgeMap writing and labeled Node, Edge or UEdge writing.

      BpUGraphWriter<ListUGraph> writer(std::cout, graph);

The writeNodeMap() function declares a NodeMap writing command in the BpUGraphWriter. 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.

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

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

      DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > 
        edgeDescMap(graph);
      writer.writeUEdgeMap("descriptor", edgeDescMap);
     
      writer.writeUEdgeMap("weight", weightMap);
      writer.writeUEdgeMap("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 writeUEdge() 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.writeUEdge("observed", uEdge);

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
#include <lemon/graph_writer.h>

List of all members.

Public Member Functions

 BpUGraphWriter (std::ostream &_os, const Graph &_graph)
 Construct a new BpUGraphWriter.
 BpUGraphWriter (const std::string &_filename, const Graph &_graph)
 Construct a new BpUGraphWriter.
 BpUGraphWriter (LemonWriter &_writer, const Graph &_graph)
 Construct a new BpUGraphWriter.
 ~BpUGraphWriter ()
template<typename Map >
BpUGraphWriterwriteNodeMap (std::string label, const Map &map)
 Issue a new node map writing command to the writer.
template<typename ItemWriter , typename Map >
BpUGraphWriterwriteNodeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
 Issue a new node map writing command to the writer.
template<typename Map >
BpUGraphWriterwriteANodeMap (std::string label, const Map &map)
 Issue a new A-node map writing command to the writer.
template<typename ItemWriter , typename Map >
BpUGraphWriterwriteANodeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
 Issue a new A-node map writing command to the writer.
template<typename Map >
BpUGraphWriterwriteBNodeMap (std::string label, const Map &map)
 Issue a new B-node map writing command to the writer.
template<typename ItemWriter , typename Map >
BpUGraphWriterwriteBNodeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
 Issue a new B-node map writing command to the writer.
template<typename Map >
BpUGraphWriterwriteEdgeMap (std::string label, const Map &map)
 Issue a new edge map writing command to the writer.
template<typename ItemWriter , typename Map >
BpUGraphWriterwriteEdgeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
 Issue a new edge map writing command to the writer.
template<typename Map >
BpUGraphWriterwriteUEdgeMap (std::string label, const Map &map)
 Issue a new undirected edge map writing command to the writer.
template<typename ItemWriter , typename Map >
BpUGraphWriterwriteUEdgeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
 Issue a new undirected edge map writing command to the writer.
BpUGraphWriterwriteNode (std::string label, const Node &node)
 Issue a new labeled node writer to the writer.
BpUGraphWriterwriteEdge (std::string label, const Edge &edge)
 Issue a new labeled edge writer to the writer.
BpUGraphWriterwriteUEdge (std::string label, const UEdge &edge)
 Issue a new labeled undirected edge writing command to the writer.
template<typename Value >
BpUGraphWriterwriteAttribute (std::string label, const Value &value)
 Issue a new attribute writing command.
template<typename ItemWriter , typename Value >
BpUGraphWriterwriteAttribute (std::string label, const Value &value, const ItemWriter &iw=ItemWriter())
 Issue a new attribute writing command.
 operator LemonWriter & ()
 Conversion operator to LemonWriter.
void run ()
bool isLabelWriter () const
 Returns true if the writer can give back the labels by the items.
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.
void writeLabel (std::ostream &os, const UEdge &item) const
 Write the label of the given undirected edge.
void sortByLabel (std::vector< Node > &nodes) const
 Sorts the given node vector by label.
void sortByLabel (std::vector< Edge > &edges) const
 Sorts the given edge vector by label.
void sortByLabel (std::vector< UEdge > &uedges) const
 Sorts the given undirected edge vector by label.


Constructor & Destructor Documentation

BpUGraphWriter ( std::ostream &  _os,
const Graph &  _graph 
) [inline]

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

BpUGraphWriter ( const std::string &  _filename,
const Graph &  _graph 
) [inline]

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

BpUGraphWriter ( LemonWriter _writer,
const Graph &  _graph 
) [inline]

Construct a new BpUGraphWriter. It writes the given graph to given LemonWriter.

~BpUGraphWriter (  )  [inline]

Destruct the graph writer.


Member Function Documentation

BpUGraphWriter& writeNodeMap ( std::string  label,
const Map &  map 
) [inline]

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

BpUGraphWriter& writeNodeMap ( std::string  label,
const Map &  map,
const ItemWriter &  iw = ItemWriter() 
) [inline]

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

BpUGraphWriter& writeANodeMap ( std::string  label,
const Map &  map 
) [inline]

This function issues a new A-node map writing command to the writer.

BpUGraphWriter& writeANodeMap ( std::string  label,
const Map &  map,
const ItemWriter &  iw = ItemWriter() 
) [inline]

This function issues a new A-node map writing command to the writer.

BpUGraphWriter& writeBNodeMap ( std::string  label,
const Map &  map 
) [inline]

This function issues a new B-node map writing command to the writer.

BpUGraphWriter& writeBNodeMap ( std::string  label,
const Map &  map,
const ItemWriter &  iw = ItemWriter() 
) [inline]

This function issues a new B-node map writing command to the writer.

BpUGraphWriter& writeEdgeMap ( std::string  label,
const Map &  map 
) [inline]

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

BpUGraphWriter& writeEdgeMap ( std::string  label,
const Map &  map,
const ItemWriter &  iw = ItemWriter() 
) [inline]

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

BpUGraphWriter& writeUEdgeMap ( std::string  label,
const Map &  map 
) [inline]

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

BpUGraphWriter& writeUEdgeMap ( std::string  label,
const Map &  map,
const ItemWriter &  iw = ItemWriter() 
) [inline]

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

BpUGraphWriter& writeNode ( std::string  label,
const Node &  node 
) [inline]

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

BpUGraphWriter& writeEdge ( std::string  label,
const Edge &  edge 
) [inline]

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

BpUGraphWriter& writeUEdge ( std::string  label,
const UEdge &  edge 
) [inline]

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

BpUGraphWriter& writeAttribute ( std::string  label,
const Value &  value 
) [inline]

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

BpUGraphWriter& writeAttribute ( std::string  label,
const Value &  value,
const ItemWriter &  iw = ItemWriter() 
) [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.

bool isLabelWriter (  )  const [inline]

Returns true if the writer can give back the the labels by the items.

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

It writes the label of the given node. If there was written a "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 a "label" named edge map then it will write the map value belonging to the edge.

void writeLabel ( std::ostream &  os,
const UEdge &  item 
) const [inline]

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

void sortByLabel ( std::vector< Node > &  nodes  )  const [inline]

Sorts the given node vector by label. If there was written an "label" named map then the vector will be sorted by the values of this map. Otherwise if the forceLabel parameter was true it will be sorted by its id in the graph.

void sortByLabel ( std::vector< Edge > &  edges  )  const [inline]

Sorts the given edge vector by label. If there was written an "label" named map then the vector will be sorted by the values of this map. Otherwise if the forceLabel parameter was true it will be sorted by its id in the graph.

void sortByLabel ( std::vector< UEdge > &  uedges  )  const [inline]

Sorts the given undirected edge vector by label. If there was written an "label" named map then the vector will be sorted by the values of this map. Otherwise if the forceLabel parameter was true it will be sorted by its id in the graph.


Generated on Thu Jun 4 04:04:53 2009 for LEMON by  doxygen 1.5.9