UEdgeSetWriter< _Graph, _Traits > Class Template Reference
[Section readers and writers]


Detailed Description

template<typename _Graph, typename _Traits = DefaultWriterTraits>
class lemon::UEdgeSetWriter< _Graph, _Traits >

The lemon format can store multiple undirected edgesets with several maps. The undirected edgeset section's header line is @uedgeset uedgeset_name, but the uedgeset_name may be empty.

The first line of the section contains the names of the maps separated with white spaces. Each next lines describes an undirected edge in the edgeset. The line contains the two connected nodes' label and the mapped values for each undirected map.

The section can handle the directed as a syntactical sugar. Two undirected edge map describes one directed edge map. This two maps are the forward map and the backward map and the names of this map is near the same just with a prefix '+' or '-' character difference.

If the edgeset contains an "label" named map then it will be regarded as label map. This map should contain only unique values and when the writeLabel() member will be called with an undirected edge it will write it's label. Otherwise if the _forceLabelMap constructor parameter is true then the label map will be the id in the graph. In addition if the the _forceSort is true then the writer will write the edges sorted by the labels.

The undirected edgeset writer needs a node label writer to identify which nodes have to be connected. If a NodeSetWriter can write the nodes' label, it will be able to use with this class. #include <lemon/lemon_writer.h>

Inheritance diagram for UEdgeSetWriter< _Graph, _Traits >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

template<typename NodeLabelWriter >
 UEdgeSetWriter (LemonWriter &_writer, const Graph &_graph, const NodeLabelWriter &_nodeLabelWriter, const std::string &_name=std::string(), bool _forceLabelMap=true, bool _forceSort=true)
 Constructor.
virtual ~UEdgeSetWriter ()
 Destructor.
template<typename Map >
UEdgeSetWriterwriteUEdgeMap (std::string label, const Map &map)
 Add a new undirected edge map writer command for the writer.
template<typename ItemWriter , typename Map >
UEdgeSetWriterwriteUEdgeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
template<typename Map >
UEdgeSetWriterwriteEdgeMap (std::string label, const Map &map)
 Add a new directed edge map writer command for the writer.
template<typename ItemWriter , typename Map >
UEdgeSetWriterwriteEdgeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
bool isLabelWriter () const
 Returns true if the undirected edgeset can write the labels of the edges.
void writeLabel (std::ostream &os, const UEdge &item) const
 Write the label of the given undirected edge.
void writeLabel (std::ostream &os, const Edge &item) const
 Write the label of the given edge.
void sortByLabel (std::vector< UEdge > &uedges) const
 Sorts the given undirected edge vector by label.
void sortByLabel (std::vector< Edge > &edges) const
 Sorts the given edge vector by label.

Protected Member Functions

virtual std::string header ()
 The header of the section.
virtual void write (std::ostream &os)
 Writer function of the section.


Constructor & Destructor Documentation

UEdgeSetWriter ( LemonWriter _writer,
const Graph &  _graph,
const NodeLabelWriter &  _nodeLabelWriter,
const std::string &  _name = std::string(),
bool  _forceLabelMap = true,
bool  _forceSort = true 
) [inline]

Constructor for UEdgeSetWriter. It creates the UEdgeSetWriter and attach it into the given LemonWriter. It will write node labels by the _nodeLabelWriter. If the _forceLabelMap parameter is true then the writer will write own label map if the user does not give "label" named map. In addition if the the _forceSort is true then the writer will write the edges sorted by the labels.

virtual ~UEdgeSetWriter (  )  [inline, virtual]

Destructor for UEdgeSetWriter.


Member Function Documentation

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

Add a new undirected map writer command for the writer.

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

Add a new undirected map writer command for the writer.

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

Add a new directed map writer command for the writer.

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

Add a new directed map writer command for the writer.

virtual std::string header (  )  [inline, protected, virtual]

It gives back the header of the section.

Implements SectionWriter.

virtual void write ( std::ostream &  os  )  [inline, protected, virtual]

Write the content of the section.

Implements SectionWriter.

bool isLabelWriter (  )  const [inline]

Returns true if the undirected edgeset can write the labels of the undirected edges. It is possible only if a "label" named map was written or the _forceLabelMap constructor parameter was true.

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 map then it will write the map value belongs to the undirected edge. Otherwise if the forceLabel parameter was true it will write its id in the graph.

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 map then it will write the map value belongs to the edge. Otherwise if the forceLabel parameter was true it will write its id in the graph. If the edge is forward map then its prefix character is '+' elsewhere '-'.

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

Sorts the given undirected edge vector by label. If there was written a "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 a "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:05:13 2009 for LEMON by  doxygen 1.5.9