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


Detailed Description

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

The lemon format can store multiple graph nodesets with several maps. The nodeset section's header line is @nodeset nodeset_name, but the nodeset_name may be empty.

The first line of the section contains the names of the maps separated with white spaces. Each next lines describes a node in the nodeset, and contains the mapped values for each map.

If the nodeset 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 a node 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 nodes sorted by the labels. #include <lemon/lemon_writer.h>

Inheritance diagram for NodeSetWriter< _Graph, _Traits >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 NodeSetWriter (LemonWriter &_writer, const Graph &_graph, const std::string &_name=std::string(), bool _forceLabelMap=true, bool _forceSort=true)
 Constructor.
virtual ~NodeSetWriter ()
 Destructor.
template<typename Map >
NodeSetWriterwriteNodeMap (std::string label, const Map &map)
template<typename ItemWriter , typename Map >
NodeSetWriterwriteNodeMap (std::string label, const Map &map, const ItemWriter &iw=ItemWriter())
bool isLabelWriter () const
 Returns true if the nodeset can write the labels of the nodes.
void writeLabel (std::ostream &os, const Node &item) const
 Write the label of the given node.
void sortByLabel (std::vector< Node > &nodes) const
 Sorts the given node 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

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

Constructor for NodeSetWriter. It creates the NodeSetWriter and attach it into the given LemonWriter. If the _forceLabelMap parameter is true then the writer will write own label map when 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 ~NodeSetWriter (  )  [inline, virtual]

Destructor for NodeSetWriter.


Member Function Documentation

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

Add a new node map writer command for the writer.

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

Add a new node 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 nodeset can write the labels of the nodes. It is possible only if a "label" named map was written or the _forceLabelMap constructor parameter was true.

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

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.


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