[Lemon-commits] [lemon_svn] deba: r2476 - in hugo/trunk: demo doc gui lemon test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:52:57 CET 2006
Author: deba
Date: Tue Jan 24 17:07:38 2006
New Revision: 2476
Modified:
hugo/trunk/demo/coloring.lgf
hugo/trunk/demo/dir_components.lgf
hugo/trunk/demo/graph_orientation.cc
hugo/trunk/demo/graph_orientation.lgf
hugo/trunk/demo/partitions.lgf
hugo/trunk/demo/route.lgf
hugo/trunk/demo/sample.lgf
hugo/trunk/demo/sub_gad_input.lgf
hugo/trunk/demo/undir_components.lgf
hugo/trunk/doc/graph_io.dox
hugo/trunk/gui/graphocska.lgf
hugo/trunk/lemon/graph_reader.h
hugo/trunk/lemon/graph_writer.h
hugo/trunk/lemon/lemon_reader.h
hugo/trunk/lemon/lemon_writer.h
hugo/trunk/test/Makefile.am
hugo/trunk/test/dijkstra_test.lgf
Log:
Lemon Graph Format uses label instead of id named map.
Modified: hugo/trunk/demo/coloring.lgf
==============================================================================
--- hugo/trunk/demo/coloring.lgf (original)
+++ hugo/trunk/demo/coloring.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-coords id
+coords label
(162, 142) 10
(169, -35) 9
(-154, -37) 8
@@ -12,7 +12,7 @@
(157, -150) 1
(-282, -149) 0
@undiredgeset
- id
+ label
9 10 17
1 9 15
3 9 14
Modified: hugo/trunk/demo/dir_components.lgf
==============================================================================
--- hugo/trunk/demo/dir_components.lgf (original)
+++ hugo/trunk/demo/dir_components.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-coordinates_x coordinates_y id
+coordinates_x coordinates_y label
218.178 27.2723 19
157.79 -130.517 18
44.8044 15.5841 17
@@ -20,7 +20,7 @@
-227.918 -40.9084 2
-389.604 -136.361 1
@edgeset
- id
+ label
17 19 23
19 18 24
18 17 25
Modified: hugo/trunk/demo/graph_orientation.cc
==============================================================================
--- hugo/trunk/demo/graph_orientation.cc (original)
+++ hugo/trunk/demo/graph_orientation.cc Tue Jan 24 17:07:38 2006
@@ -49,13 +49,13 @@
ListGraph g;
ListGraph::NodeMap<int> f(g); //in-deg requirement;
- ListGraph::NodeMap<int> id(g);
+ ListGraph::NodeMap<int> label(g);
ListGraph::NodeMap<xy<double> > coords(g);
try {
GraphReader<ListGraph> reader(argv[1],g);
reader.readNodeMap("f",f);
- reader.readNodeMap("id",id);
+ reader.readNodeMap("label",label);
reader.readNodeMap("coordinates_x",xMap(coords));
reader.readNodeMap("coordinates_y",yMap(coords));
reader.run();
@@ -80,15 +80,15 @@
Node act;
while((act=IterableBoolNodeMap<ListGraph>::TrueIt(active))!=INVALID) {
- std::cout << "Process node " << id[act]
+ std::cout << "Process node " << label[act]
<< " (def=" << def[act]
<< " lev=" << level[act] << "): ";
OutEdgeIt e(g,act);
while(e!=INVALID && level[g.target(e)]>=level[act]) ++e;
if(e!=INVALID) {
std::cout << " REVERT EDGE " << g.id(e)
- << " (" << id[g.source(e)] << "---"
- << id[g.target(e)] << ")"
+ << " (" << label[g.source(e)] << "---"
+ << label[g.target(e)] << ")"
<< std::endl;
if(--def[act]==0) active[act]=false;
if(++def[g.target(e)]>0) active[g.target(e)]=true;
Modified: hugo/trunk/demo/graph_orientation.lgf
==============================================================================
--- hugo/trunk/demo/graph_orientation.lgf (original)
+++ hugo/trunk/demo/graph_orientation.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-coordinates_x coordinates_y f id
+coordinates_x coordinates_y f label
-198 -73 2 7
120 30 4 6
-17 222 1 5
@@ -8,7 +8,7 @@
-28 -93 1 2
-131 83 3 1
@edgeset
- id
+ label
7 6 3
1 6 2
2 6 1
Modified: hugo/trunk/demo/partitions.lgf
==============================================================================
--- hugo/trunk/demo/partitions.lgf (original)
+++ hugo/trunk/demo/partitions.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-coordinates_x coordinates_y id
+coordinates_x coordinates_y label
513.857 -446.322 23
393.468 566.711 22
869.153 52.8539 21
@@ -24,7 +24,7 @@
-607.82 -246.651 2
-274 -131 1
@undiredgeset
- id
+ label
12 23 15
13 23 14
4 22 23
Modified: hugo/trunk/demo/route.lgf
==============================================================================
--- hugo/trunk/demo/route.lgf (original)
+++ hugo/trunk/demo/route.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-id coordinates_x coordinates_y
+label coordinates_x coordinates_y
9 447.907 578.328
8 79.2573 909.464
7 878.677 960.04
@@ -11,7 +11,7 @@
1 408.248 577.327
0 189.239 92.5316
@edgeset
- length id
+ length label
2 3 901.074 0
8 5 270.85 1
6 9 601.553 2
Modified: hugo/trunk/demo/sample.lgf
==============================================================================
--- hugo/trunk/demo/sample.lgf (original)
+++ hugo/trunk/demo/sample.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-id coordinates_x coordinates_y
+label coordinates_x coordinates_y
5 796.398 208.035
4 573.002 63.002
3 568.549 401.748
@@ -7,7 +7,7 @@
1 288.248 397.327
0 102.239 257.532
@edgeset
- id capacity
+ label capacity
4 5 6 8
3 5 5 8
2 4 4 5
Modified: hugo/trunk/demo/sub_gad_input.lgf
==============================================================================
--- hugo/trunk/demo/sub_gad_input.lgf (original)
+++ hugo/trunk/demo/sub_gad_input.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-id
+label
6
5
4
@@ -8,7 +8,7 @@
1
0
@edgeset
- id length
+ label length
5 6 9 4
4 6 8 2
3 5 7 1
Modified: hugo/trunk/demo/undir_components.lgf
==============================================================================
--- hugo/trunk/demo/undir_components.lgf (original)
+++ hugo/trunk/demo/undir_components.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-coordinates_x coordinates_y id
+coordinates_x coordinates_y label
574.035 177.301 44
694.579 115.483 43
280.402 10.3938 42
@@ -44,7 +44,7 @@
-689.204 -237.261 32
-567.302 43.6423 33
@undiredgeset
- id
+ label
41 42 44
40 42 43
37 40 49
Modified: hugo/trunk/doc/graph_io.dox
==============================================================================
--- hugo/trunk/doc/graph_io.dox (original)
+++ hugo/trunk/doc/graph_io.dox Tue Jan 24 17:07:38 2006
@@ -31,13 +31,13 @@
The next line contains the names of the nodemaps, separated by whitespaces. Each
following line describes a node in the graph: it contains the values of the
-maps in the right order. The map named "id" should contain unique values
-because it is regarded as an ID-map. These ids need not be numbers but they
+maps in the right order. The map named "label" should contain unique values
+because it is regarded as a label map. These labels need not be numbers but they
must identify the nodes uniquely for later reference. For example:
\code
@nodeset
-id x-coord y-coord color
+label x-coord y-coord color
3 1.0 4.0 blue
5 2.3 5.7 red
12 7.8 2.3 green
@@ -50,17 +50,17 @@
The next line contains the whitespace separated list of names of the edge
maps. Each of the next lines describes one edge. The first two elements in
-the line are the IDs of the source and target (or tail and head) nodes of the
-edge as they occur in the ID node map of the nodeset section. You can also
-have an optional ID map on the edges for later reference (which has to be
+the line are the labels of the source and target (or tail and head) nodes of the
+edge as they occur in the label node map of the nodeset section. You can also
+have an optional label map on the edges for later reference (which has to be
unique in this case).
\code
@edgeset
- id weight label
-3 5 a 4.3 a-edge
-5 12 c 2.6 c-edge
-3 12 g 3.4 g-edge
+ label weight note
+3 5 a 4.3 a-edge
+5 12 c 2.6 c-edge
+3 12 g 3.4 g-edge
\endcode
The \e nodes section contains <em>labeled (distinguished) nodes</em>
@@ -70,7 +70,7 @@
<tt> \@nodes </tt>
Each of the next lines contains a label for a node in the graph
-and then the ID as described in the \e nodeset section.
+and then the label as described in the \e nodeset section.
\code
@nodes
@@ -80,7 +80,7 @@
The last section describes the <em>labeled (distinguished) edges</em>
(i.e. edges having a special label on them). It starts with \c \@edges
-and then each line contains the name of the edge and the ID.
+and then each line contains the name of the edge and the label.
\code
@edges
@@ -103,9 +103,7 @@
version 12
\endcode
-<tt> \@end </tt>
-
-line.
+Finally, the file should be closed with \c \@end line.
\section use Using graph input-output
@@ -132,14 +130,14 @@
function declares a \c NodeMap writing command in the
\ref lemon::GraphWriter "GraphWriter".
You should give a name to the map and the map
-object as parameters. The NodeMap writing command with name "id" should write a
-unique map because it will be regarded as an ID map.
+object as parameters. The NodeMap writing command with name "label" should write a
+unique map because it will be regarded as a label map.
\see IdMap, DescriptorMap
\code
-IdMap<ListGraph, Node> nodeIdMap;
-writer.writeNodeMap("id", nodeIdMap);
+IdMap<ListGraph, Node> nodeLabelMap;
+writer.writeNodeMap("label", nodeLabelMap);
writer.writeNodeMap("x-coord", xCoordMap);
writer.writeNodeMap("y-coord", yCoordMap);
@@ -157,7 +155,7 @@
writer.writeEdgeMap("descriptor", edgeDescMap);
writer.writeEdgeMap("weight", weightMap);
-writer.writeEdgeMap("label", labelMap);
+writer.writeEdgeMap("note", noteMap);
\endcode
With \ref lemon::GraphWriter::writeNode() "writeNode()"
@@ -314,10 +312,10 @@
The global functionality of the reader class can be changed by giving a
special template parameter to the GraphReader class. By default, the
template parameter is \c DefaultReaderTraits. A reader traits class
-should provide an inner template class Reader for each type, and a
+should provide a nested template class Reader for each type, and a
DefaultReader for skipping a value.
-The specialization of writing is very similar to that of reading.
+The specialization of writing is very similar to that of reading.
\section undir Undirected graphs
@@ -333,10 +331,10 @@
\code
@undiredgeset
- id capacity +flow -flow
-32 2 1 4.3 2.0 0.0
-21 21 5 2.6 0.0 2.6
-21 12 8 3.4 0.0 0.0
+ label capacity +flow -flow
+32 2 1 4.3 2.0 0.0
+21 21 5 2.6 0.0 2.6
+21 12 8 3.4 0.0 0.0
\endcode
The \c edges section is changed to \c undiredges section. This section
@@ -461,7 +459,7 @@
Because both the \ref lemon::GraphReader "GraphReader"
and the \ref lemon::UndirGraphReader "UndirGraphReader" can be converted
to \ref lemon::LemonReader "LemonReader"
-and it can resolve the ID's of the items, the previous
+and it can resolve the label's of the items, the previous
result can be achived with the \ref lemon::UndirGraphReader "UndirGraphReader"
class, too.
Modified: hugo/trunk/gui/graphocska.lgf
==============================================================================
--- hugo/trunk/gui/graphocska.lgf (original)
+++ hugo/trunk/gui/graphocska.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-id coordinates_x coordinates_y data
+label coordinates_x coordinates_y data
1 230 -80 1.123
2 230 100 3.234
3 120 -80 5.345
Modified: hugo/trunk/lemon/graph_reader.h
==============================================================================
--- hugo/trunk/lemon/graph_reader.h (original)
+++ hugo/trunk/lemon/graph_reader.h Tue Jan 24 17:07:38 2006
@@ -67,8 +67,7 @@
/// \code
/// reader.readNodeMap("coords", coords);
///
- /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
- /// reader.skipNodeMap<QuotedStringReader>("description");
+ /// reader.skipNodeMap("description", desc);
///
/// reader.readNodeMap("color", colorMap);
/// \endcode
@@ -306,20 +305,28 @@
reader->run();
}
- /// \brief Gives back the node by its id.
+
+ /// \brief Returns true if the reader can give back the items by its label.
+ ///
+ /// \brief Returns true if the reader can give back the items by its label.
+ bool isLabelReader() const {
+ return nodeset_reader.isLabelReader() && edgeset_reader.isLabelReader();
+ }
+
+ /// \brief Gives back the node by its label.
///
- /// It reads an id from the stream and gives back which node belongs to
- /// it. It is possible only if there was read an "id" named node map.
- Node readId(std::istream& is, Node) const {
- return nodeset_reader.readId(is, Node());
+ /// It reads an label from the stream and gives back which node belongs to
+ /// it. It is possible only if there was read an "label" named node map.
+ void readLabel(std::istream& is, Node& node) const {
+ nodeset_reader.readLabel(is, node);
}
- /// \brief Gives back the edge by its id.
+ /// \brief Gives back the edge by its label.
///
- /// It reads an id from the stream and gives back which edge belongs to
- /// it. It is possible only if there was read an "id" named edge map.
- Edge readId(std::istream& is, Edge) const {
- return edgeset_reader.readId(is, Edge());
+ /// It reads an label from the stream and gives back which edge belongs to
+ /// it. It is possible only if there was read an "label" named edge map.
+ void readLabel(std::istream& is, Edge& edge) const {
+ return edgeset_reader.readLabel(is, edge);
}
private:
@@ -404,8 +411,7 @@
/// \code
/// reader.readNodeMap("coords", coords);
///
- /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
- /// reader.skipNodeMap<QuotedStringReader>("description");
+ /// reader.skipNodeMap("description", desc);
///
/// reader.readNodeMap("color", colorMap);
/// \endcode
@@ -704,29 +710,38 @@
reader->run();
}
- /// \brief Gives back the node by its id.
+
+ /// \brief Returns true if the reader can give back the items by its label.
+ ///
+ /// \brief Returns true if the reader can give back the items by its label.
+ bool isLabelReader() const {
+ return nodeset_reader.isLabelReader() &&
+ undir_edgeset_reader.isLabelReader();
+ }
+
+ /// \brief Gives back the node by its label.
///
- /// It reads an id from the stream and gives back which node belongs to
- /// it. It is possible only if there was read an "id" named node map.
- Node readId(std::istream& is, Node) const {
- return nodeset_reader.readId(is, Node());
+ /// It reads an label from the stream and gives back which node belongs to
+ /// it. It is possible only if there was read an "label" named node map.
+ void readLabel(std::istream& is, Node& node) const {
+ return nodeset_reader.readLabel(is, node);
}
- /// \brief Gives back the edge by its id.
+ /// \brief Gives back the edge by its label.
///
- /// It reads an id from the stream and gives back which edge belongs to
- /// it. It is possible only if there was read an "id" named edge map.
- Edge readId(std::istream& is, Edge) const {
- return undir_edgeset_reader.readId(is, Edge());
+ /// It reads an label from the stream and gives back which edge belongs to
+ /// it. It is possible only if there was read an "label" named edge map.
+ void readLabel(std::istream& is, Edge& edge) const {
+ return undir_edgeset_reader.readLabel(is, edge);
}
- /// \brief Gives back the undirected edge by its id.
+ /// \brief Gives back the undirected edge by its label.
///
- /// It reads an id from the stream and gives back which undirected edge
- /// belongs to it. It is possible only if there was read an "id" named
+ /// It reads an label from the stream and gives back which undirected edge
+ /// belongs to it. It is possible only if there was read an "label" named
/// edge map.
- UndirEdge readId(std::istream& is, UndirEdge) const {
- return undir_edgeset_reader.readId(is, UndirEdge());
+ void readLabel(std::istream& is, UndirEdge& uedge) const {
+ return undir_edgeset_reader.readLabel(is, uedge);
}
Modified: hugo/trunk/lemon/graph_writer.h
==============================================================================
--- hugo/trunk/lemon/graph_writer.h (original)
+++ hugo/trunk/lemon/graph_writer.h Tue Jan 24 17:07:38 2006
@@ -54,12 +54,12 @@
/// The \c writeNodeMap() function declares a \c NodeMap writing
/// command in the \c GraphWriter. 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 (such a map is essential if the graph has edges).
+ /// 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).
///
/// \code
- /// IdMap<ListGraph, Node> nodeIdMap;
- /// writer.writeNodeMap("id", nodeIdMap);
+ /// IdMap<ListGraph, Node> nodeLabelMap;
+ /// writer.writeNodeMap("label", nodeLabelMap);
///
/// writer.writeNodeMap("coords", coords);
/// writer.writeNodeMap("color", colorMap);
@@ -253,20 +253,20 @@
writer->run();
}
- /// \brief Write the id of the given node.
+ /// \brief Write the label of the given node.
///
- /// It writes the id of the given node. If there was written an "id"
+ /// 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 writeId(std::ostream& os, const Node& item) const {
- nodeset_writer.writeId(os, item);
+ void writeLabel(std::ostream& os, const Node& item) const {
+ nodeset_writer.writeLabel(os, item);
}
- /// \brief Write the id of the given edge.
+ /// \brief Write the label of the given edge.
///
- /// It writes the id of the given edge. If there was written an "id"
+ /// 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.
- void writeId(std::ostream& os, const Edge& item) const {
- edgeset_writer.writeId(os, item);
+ void writeLabel(std::ostream& os, const Edge& item) const {
+ edgeset_writer.writeLabel(os, item);
}
private:
@@ -327,12 +327,12 @@
/// The \c writeNodeMap() function declares a \c NodeMap writing
/// command in the \c 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.
+ /// command with name "label" should write a unique map because it
+ /// is regarded as label map.
///
/// \code
- /// IdMap<UndirListGraph, Node> nodeIdMap;
- /// writer.writeNodeMap("id", nodeIdMap);
+ /// IdMap<UndirListGraph, Node> nodeLabelMap;
+ /// writer.writeNodeMap("label", nodeLabelMap);
///
/// writer.writeNodeMap("coords", coords);
/// writer.writeNodeMap("color", colorMap);
@@ -561,29 +561,29 @@
writer->run();
}
- /// \brief Write the id of the given node.
+ /// \brief Write the label of the given node.
///
- /// It writes the id of the given node. If there was written an "id"
+ /// 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 writeId(std::ostream& os, const Node& item) const {
- nodeset_writer.writeId(os, item);
+ void writeLabel(std::ostream& os, const Node& item) const {
+ nodeset_writer.writeLabel(os, item);
}
- /// \brief Write the id of the given edge.
+ /// \brief Write the label of the given edge.
///
- /// It writes the id of the given edge. If there was written an "id"
+ /// 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.
- void writeId(std::ostream& os, const Edge& item) const {
- undir_edgeset_writer.writeId(os, item);
+ void writeLabel(std::ostream& os, const Edge& item) const {
+ undir_edgeset_writer.writeLabel(os, item);
}
- /// \brief Write the id of the given undirected edge.
+ /// \brief Write the label of the given undirected edge.
///
- /// 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
+ /// It writes the label of the given undirected edge. If there was written
+ /// an "label" named edge map then it will write the map value belonging to
/// the edge.
- void writeId(std::ostream& os, const UndirEdge& item) const {
- undir_edgeset_writer.writeId(os, item);
+ void writeLabel(std::ostream& os, const UndirEdge& item) const {
+ undir_edgeset_writer.writeLabel(os, item);
}
Modified: hugo/trunk/lemon/lemon_reader.h
==============================================================================
--- hugo/trunk/lemon/lemon_reader.h (original)
+++ hugo/trunk/lemon/lemon_reader.h Tue Jan 24 17:07:38 2006
@@ -47,7 +47,7 @@
template <typename T>
bool operator<(T, T) {
- throw DataFormatError("Id is not comparable");
+ throw DataFormatError("Label is not comparable");
}
template <typename T>
@@ -58,22 +58,22 @@
};
template <typename Item>
- class ItemIdReader {
+ class ItemLabelReader {
public:
- bool isIdReader() { return true; }
+ bool isLabelReader() { return true; }
- void readId(std::istream&, Item&) {}
+ void readLabel(std::istream&, Item&) {}
- template <class _ItemIdReader>
+ template <class _ItemLabelReader>
struct Constraints {
void constraints() {
- bool b = reader.isIdReader();
+ bool b = reader.isLabelReader();
ignore_unused_variable_warning(b);
Item item;
- reader.readId(is, item);
+ reader.readLabel(is, item);
}
- _ItemIdReader& reader;
+ _ItemLabelReader& reader;
std::istream& is;
};
@@ -241,7 +241,7 @@
if (it == inverse.end()) {
inverse.insert(std::make_pair(value, item));
} else {
- throw DataFormatError("Multiple ID occurence");
+ throw DataFormatError("Multiple label occurence");
}
}
@@ -252,7 +252,7 @@
if (it != inverse.end()) {
return it->second;
} else {
- throw DataFormatError("Invalid ID error");
+ throw DataFormatError("Invalid label error");
}
}
};
@@ -279,7 +279,7 @@
if (it == inverse.end()) {
inverse.insert(std::make_pair(value, item));
} else {
- throw DataFormatError("Multiple ID occurence error");
+ throw DataFormatError("Multiple label occurence error");
}
}
@@ -290,7 +290,7 @@
if (it != inverse.end()) {
return it->second;
} else {
- throw DataFormatError("Invalid ID error");
+ throw DataFormatError("Invalid label error");
}
}
@@ -370,33 +370,33 @@
};
template <typename _Item>
- class IdReaderBase {
+ class LabelReaderBase {
public:
typedef _Item Item;
- virtual ~IdReaderBase() {}
+ virtual ~LabelReaderBase() {}
virtual Item read(std::istream& is) const = 0;
- virtual bool isIdReader() const = 0;
+ virtual bool isLabelReader() const = 0;
};
- template <typename _Item, typename _BoxedIdReader>
- class IdReader : public IdReaderBase<_Item> {
+ template <typename _Item, typename _BoxedLabelReader>
+ class LabelReader : public LabelReaderBase<_Item> {
public:
typedef _Item Item;
- typedef _BoxedIdReader BoxedIdReader;
+ typedef _BoxedLabelReader BoxedLabelReader;
- const BoxedIdReader& boxedIdReader;
+ const BoxedLabelReader& boxedLabelReader;
- IdReader(const BoxedIdReader& _boxedIdReader)
- : boxedIdReader(_boxedIdReader) {}
+ LabelReader(const BoxedLabelReader& _boxedLabelReader)
+ : boxedLabelReader(_boxedLabelReader) {}
virtual Item read(std::istream& is) const {
Item item;
- boxedIdReader.readId(is, item);
+ boxedLabelReader.readLabel(is, item);
return item;
}
- virtual bool isIdReader() const {
- return boxedIdReader.isIdReader();
+ virtual bool isLabelReader() const {
+ return boxedLabelReader.isLabelReader();
}
};
@@ -727,16 +727,16 @@
/// \brief SectionReader for reading a graph's nodeset.
///
/// The lemon format can store multiple graph nodesets with several maps.
- /// The nodeset section's header line is \c \@nodeset \c nodeset_id, but the
- /// \c nodeset_id may be empty.
+ /// The nodeset section's header line is \c \@nodeset \c nodeset_name, but the
+ /// \c 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 \c "id" named map then it will be regarded
+ /// If the nodeset contains an \c "label" named map then it will be regarded
/// as id map. This map should contain only unique values and when the
- /// \c readId() member will read a value from the given stream it will
+ /// \c readLabel() member will read a value from the given stream it will
/// give back that node which is mapped to this value.
///
/// \relates LemonReader
@@ -755,12 +755,12 @@
/// Constructor for NodeSetReader. It creates the NodeSetReader and
/// attach it into the given LemonReader. The nodeset reader will
/// add the readed nodes to the given Graph. The reader will read
- /// the section when the \c section_id and the \c _id are the same.
+ /// the section when the \c section_name and the \c _name are the same.
NodeSetReader(LemonReader& _reader,
Graph& _graph,
- const std::string& _id = std::string(),
+ const std::string& _name = std::string(),
const DefaultSkipper& _skipper = DefaultSkipper())
- : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {}
+ : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) {}
/// \brief Destructor.
@@ -855,11 +855,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line starts with \c \@nodeset,
- /// and the header line's id and the nodeset's id are the same.
+ /// and the header line's name and the nodeset's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@nodeset" && name == id;
}
@@ -872,7 +872,8 @@
std::string line;
getline(is, line);
- std::istringstream ls(line);
+ std::istringstream ls(line);
+ std::string id;
while (ls >> id) {
typename MapReaders::iterator it = readers.find(id);
if (it != readers.end()) {
@@ -881,7 +882,7 @@
} else {
index.push_back(&skipper);
}
- if (id == "id" && inverter.get() == 0) {
+ if (id == "label" || (id =="id" && inverter.get() == 0)) {
inverter.reset(index.back()->getInverter());
index.back() = inverter.get();
}
@@ -905,19 +906,19 @@
public:
- /// \brief Returns true if the nodeset can give back the node by its id.
+ /// \brief Returns true if the nodeset can give back the node by its label.
///
- /// Returns true if the nodeset can give back the node by its id.
- /// It is possible only if an "id" named map was read.
- bool isIdReader() const {
+ /// Returns true if the nodeset can give back the node by its label.
+ /// It is possible only if an "label" named map was read.
+ bool isLabelReader() const {
return inverter.get() != 0;
}
- /// \brief Gives back the node by its id.
+ /// \brief Gives back the node by its label.
///
/// It reads an id from the stream and gives back which node belongs to
- /// it. It is possible only if there was read an "id" named map.
- void readId(std::istream& is, Node& node) const {
+ /// it. It is possible only if there was read an "label" named map.
+ void readLabel(std::istream& is, Node& node) const {
node = inverter->read(is);
}
@@ -927,7 +928,7 @@
MapReaders readers;
Graph& graph;
- std::string id;
+ std::string name;
_reader_bits::SkipReader<Node, DefaultSkipper> skipper;
std::auto_ptr<_reader_bits::MapInverterBase<Node> > inverter;
@@ -937,21 +938,21 @@
/// \brief SectionReader for reading a graph's edgeset.
///
/// The lemon format can store multiple graph edgesets with several maps.
- /// The edgeset section's header line is \c \@edgeset \c edgeset_id, but the
- /// \c edgeset_id may be empty.
+ /// The edgeset section's header line is \c \@edgeset \c edgeset_name, but the
+ /// \c edgeset_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 edge in the edgeset. The
/// line contains the source and the target nodes' id and the mapped
/// values for each map.
///
- /// If the edgeset contains an \c "id" named map then it will be regarded
+ /// If the edgeset contains an \c "label" named map then it will be regarded
/// as id map. This map should contain only unique values and when the
- /// \c readId() member will read a value from the given stream it will
+ /// \c readLabel() member will read a value from the given stream it will
/// give back that edge which is mapped to this value.
///
/// The edgeset reader needs a node id reader to identify which nodes
- /// have to be connected. If a NodeSetReader reads an "id" named map,
+ /// have to be connected. If a NodeSetReader reads an "label" named map,
/// it will be able to resolve the nodes by ids.
///
/// \relates LemonReader
@@ -972,18 +973,18 @@
/// attach it into the given LemonReader. The edgeset reader will
/// add the readed edges to the given Graph. It will use the given
/// node id reader to read the source and target nodes of the edges.
- /// The reader will read the section only if the \c _id and the
- /// \c edgset_id are the same.
- template <typename NodeIdReader>
+ /// The reader will read the section only if the \c _name and the
+ /// \c edgset_name are the same.
+ template <typename NodeLabelReader>
EdgeSetReader(LemonReader& _reader,
Graph& _graph,
- const NodeIdReader& _nodeIdReader,
- const std::string& _id = std::string(),
+ const NodeLabelReader& _nodeLabelReader,
+ const std::string& _name = std::string(),
const DefaultSkipper& _skipper = DefaultSkipper())
- : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
- checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
- nodeIdReader.reset(new _reader_bits::
- IdReader<Node, NodeIdReader>(_nodeIdReader));
+ : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) {
+ checkConcept<_reader_bits::ItemLabelReader<Node>, NodeLabelReader>();
+ nodeLabelReader.reset(new _reader_bits::
+ LabelReader<Node, NodeLabelReader>(_nodeLabelReader));
}
/// \brief Destructor.
///
@@ -1077,11 +1078,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line starts with \c \@edgeset,
- /// and the header line's id and the edgeset's id are the same.
+ /// and the header line's name and the edgeset's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@edgeset" && name == id;
}
@@ -1090,14 +1091,15 @@
///
/// It reads the content of the section.
virtual void read(std::istream& is) {
- if (!nodeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!nodeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
std::vector<_reader_bits::MapReaderBase<Edge>* > index;
std::string line;
getline(is, line);
std::istringstream ls(line);
+ std::string id;
while (ls >> id) {
typename MapReaders::iterator it = readers.find(id);
if (it != readers.end()) {
@@ -1106,7 +1108,7 @@
} else {
index.push_back(&skipper);
}
- if (id == "id" && inverter.get() == 0) {
+ if (id == "label" || (id =="id" && inverter.get() == 0)) {
inverter.reset(index.back()->getInverter());
index.back() = inverter.get();
}
@@ -1121,8 +1123,8 @@
}
while (getline(is, line)) {
std::istringstream ls(line);
- Node from = nodeIdReader->read(ls);
- Node to = nodeIdReader->read(ls);
+ Node from = nodeLabelReader->read(ls);
+ Node to = nodeLabelReader->read(ls);
Edge edge = graph.addEdge(from, to);
for (int i = 0; i < (int)index.size(); ++i) {
index[i]->read(ls, edge);
@@ -1132,19 +1134,19 @@
public:
- /// \brief Returns true if the edgeset can give back the edge by its id.
+ /// \brief Returns true if the edgeset can give back the edge by its label.
///
- /// Returns true if the edgeset can give back the edge by its id.
- /// It is possible only if an "id" named map was read.
- bool isIdReader() const {
+ /// Returns true if the edgeset can give back the edge by its label.
+ /// It is possible only if an "label" named map was read.
+ bool isLabelReader() const {
return inverter.get() != 0;
}
- /// \brief Gives back the edge by its id.
+ /// \brief Gives back the edge by its label.
///
/// It reads an id from the stream and gives back which edge belongs to
- /// it. It is possible only if there was read an "id" named map.
- void readId(std::istream& is, Edge& edge) const {
+ /// it. It is possible only if there was read an "label" named map.
+ void readLabel(std::istream& is, Edge& edge) const {
edge = inverter->read(is);
}
@@ -1154,11 +1156,11 @@
MapReaders readers;
Graph& graph;
- std::string id;
+ std::string name;
_reader_bits::SkipReader<Edge, DefaultSkipper> skipper;
std::auto_ptr<_reader_bits::MapInverterBase<Edge> > inverter;
- std::auto_ptr<_reader_bits::IdReaderBase<Node> > nodeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<Node> > nodeLabelReader;
};
/// \ingroup io_group
@@ -1166,7 +1168,7 @@
///
/// The lemon format can store multiple undirected edgesets with several
/// maps. The undirected edgeset section's header line is \c \@undiredgeset
- /// \c undiredgeset_id, but the \c undiredgeset_id may be empty.
+ /// \c undiredgeset_name, but the \c undiredgeset_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 edge in the edgeset. The
@@ -1178,13 +1180,13 @@
/// is near the same just with a prefix \c '+' or \c '-' character
/// difference.
///
- /// If the edgeset contains an \c "id" named map then it will be regarded
+ /// If the edgeset contains an \c "label" named map then it will be regarded
/// as id map. This map should contain only unique values and when the
- /// \c readId() member will read a value from the given stream it will
+ /// \c readLabel() member will read a value from the given stream it will
/// give back that undiricted edge which is mapped to this value.
///
/// The undirected edgeset reader needs a node id reader to identify which
- /// nodes have to be connected. If a NodeSetReader reads an "id" named map,
+ /// nodes have to be connected. If a NodeSetReader reads an "label" named map,
/// it will be able to resolve the nodes by ids.
///
/// \relates LemonReader
@@ -1207,17 +1209,17 @@
/// reader will add the readed undirected edges to the given Graph. It
/// will use the given node id reader to read the source and target
/// nodes of the edges. The reader will read the section only if the
- /// \c _id and the \c undiredgset_id are the same.
- template <typename NodeIdReader>
+ /// \c _name and the \c undiredgset_name are the same.
+ template <typename NodeLabelReader>
UndirEdgeSetReader(LemonReader& _reader,
Graph& _graph,
- const NodeIdReader& _nodeIdReader,
- const std::string& _id = std::string(),
+ const NodeLabelReader& _nodeLabelReader,
+ const std::string& _name = std::string(),
const DefaultSkipper& _skipper = DefaultSkipper())
- : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
- checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
- nodeIdReader.reset(new _reader_bits::
- IdReader<Node, NodeIdReader>(_nodeIdReader));
+ : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) {
+ checkConcept<_reader_bits::ItemLabelReader<Node>, NodeLabelReader>();
+ nodeLabelReader.reset(new _reader_bits::
+ LabelReader<Node, NodeLabelReader>(_nodeLabelReader));
}
/// \brief Destructor.
///
@@ -1372,11 +1374,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line starts with \c \@undiredgeset,
- /// and the header line's id and the edgeset's id are the same.
+ /// and the header line's name and the edgeset's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@undiredgeset" && name == id;
}
@@ -1385,14 +1387,15 @@
///
/// It reads the content of the section.
virtual void read(std::istream& is) {
- if (!nodeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!nodeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
std::vector<_reader_bits::MapReaderBase<UndirEdge>* > index;
std::string line;
getline(is, line);
std::istringstream ls(line);
+ std::string id;
while (ls >> id) {
typename MapReaders::iterator it = readers.find(id);
if (it != readers.end()) {
@@ -1401,7 +1404,7 @@
} else {
index.push_back(&skipper);
}
- if (id == "id" && inverter.get() == 0) {
+ if (id == "label" || (id =="id" && inverter.get() == 0)) {
inverter.reset(index.back()->getInverter());
index.back() = inverter.get();
}
@@ -1416,8 +1419,8 @@
}
while (getline(is, line)) {
std::istringstream ls(line);
- Node from = nodeIdReader->read(ls);
- Node to = nodeIdReader->read(ls);
+ Node from = nodeLabelReader->read(ls);
+ Node to = nodeLabelReader->read(ls);
UndirEdge edge = graph.addEdge(from, to);
for (int i = 0; i < (int)index.size(); ++i) {
index[i]->read(ls, edge);
@@ -1427,29 +1430,29 @@
public:
- /// \brief Returns true if the edgeset can give back the edge by its id.
+ /// \brief Returns true if the edgeset can give back the edge by its label.
///
/// Returns true if the edgeset can give back the undirected edge by its
- /// id. It is possible only if an "id" named map was read.
- bool isIdReader() const {
+ /// id. It is possible only if an "label" named map was read.
+ bool isLabelReader() const {
return inverter.get() != 0;
}
- /// \brief Gives back the undirected edge by its id.
+ /// \brief Gives back the undirected edge by its label.
///
/// It reads an id from the stream and gives back which undirected edge
- /// belongs to it. It is possible only if there was read an "id" named map.
- void readId(std::istream& is, UndirEdge& undirEdge) const {
+ /// belongs to it. It is possible only if there was read an "label" named map.
+ void readLabel(std::istream& is, UndirEdge& undirEdge) const {
undirEdge = inverter->read(is);
}
- /// \brief Gives back the directed edge by its id.
+ /// \brief Gives back the directed edge by its label.
///
/// It reads an id from the stream and gives back which directed edge
/// belongs to it. The directed edge id is the \c '+' or \c '-' character
/// and the undirected edge id. It is possible only if there was read
- /// an "id" named map.
- void readId(std::istream& is, Edge& edge) const {
+ /// an "label" named map.
+ void readLabel(std::istream& is, Edge& edge) const {
char c;
is >> c;
UndirEdge undirEdge = inverter->read(is);
@@ -1470,18 +1473,18 @@
MapReaders readers;
Graph& graph;
- std::string id;
+ std::string name;
_reader_bits::SkipReader<UndirEdge, DefaultSkipper> skipper;
std::auto_ptr<_reader_bits::MapInverterBase<UndirEdge> > inverter;
- std::auto_ptr<_reader_bits::IdReaderBase<Node> > nodeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<Node> > nodeLabelReader;
};
/// \ingroup io_group
/// \brief SectionReader for reading labeled nodes.
///
- /// The nodes section's header line is \c \@nodes \c nodes_id, but the
- /// \c nodes_id may be empty.
+ /// The nodes section's header line is \c \@nodes \c nodes_name, but the
+ /// \c nodes_name may be empty.
///
/// Each line in the section contains the name of the node
/// and then the node id.
@@ -1499,14 +1502,14 @@
/// Constructor for NodeReader. It creates the NodeReader and
/// attach it into the given LemonReader. It will use the given
/// node id reader to give back the nodes. The reader will read the
- /// section only if the \c _id and the \c nodes_id are the same.
- template <typename _IdReader>
- NodeReader(LemonReader& _reader, const _IdReader& _idReader,
- const std::string& _id = std::string())
- : Parent(_reader), id(_id) {
- checkConcept<_reader_bits::ItemIdReader<Node>, _IdReader>();
- nodeIdReader.reset(new _reader_bits::
- IdReader<Node, _IdReader>(_idReader));
+ /// section only if the \c _name and the \c nodes_name are the same.
+ template <typename _LabelReader>
+ NodeReader(LemonReader& _reader, const _LabelReader& _labelReader,
+ const std::string& _name = std::string())
+ : Parent(_reader), name(_name) {
+ checkConcept<_reader_bits::ItemLabelReader<Node>, _LabelReader>();
+ nodeLabelReader.reset(new _reader_bits::
+ LabelReader<Node, _LabelReader>(_labelReader));
}
/// \brief Destructor.
@@ -1538,11 +1541,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line start with \c \@nodes,
- /// and the header line's id and the reader's id are the same.
+ /// and the header line's name and the reader's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@nodes" && name == id;
}
@@ -1551,8 +1554,8 @@
///
/// It reads the content of the section.
virtual void read(std::istream& is) {
- if (!nodeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!nodeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
std::string line;
while (getline(is, line)) {
@@ -1561,7 +1564,7 @@
ls >> id;
typename NodeReaders::iterator it = readers.find(id);
if (it != readers.end()) {
- it->second.read(nodeIdReader->read(ls));
+ it->second.read(nodeLabelReader->read(ls));
it->second.touch();
}
}
@@ -1577,18 +1580,18 @@
private:
- std::string id;
+ std::string name;
typedef std::map<std::string, _reader_bits::ItemStore<Node> > NodeReaders;
NodeReaders readers;
- std::auto_ptr<_reader_bits::IdReaderBase<Node> > nodeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<Node> > nodeLabelReader;
};
/// \ingroup io_group
/// \brief SectionReader for reading labeled edges.
///
- /// The edges section's header line is \c \@edges \c edges_id, but the
- /// \c edges_id may be empty.
+ /// The edges section's header line is \c \@edges \c edges_name, but the
+ /// \c edges_name may be empty.
///
/// Each line in the section contains the name of the edge
/// and then the edge id.
@@ -1606,14 +1609,14 @@
/// Constructor for EdgeReader. It creates the EdgeReader and
/// attach it into the given LemonReader. It will use the given
/// edge id reader to give back the edges. The reader will read the
- /// section only if the \c _id and the \c edges_id are the same.
- template <typename _IdReader>
- EdgeReader(LemonReader& _reader, const _IdReader& _idReader,
- const std::string& _id = std::string())
- : Parent(_reader), id(_id) {
- checkConcept<_reader_bits::ItemIdReader<Edge>, _IdReader>();
- edgeIdReader.reset(new _reader_bits::
- IdReader<Edge, _IdReader>(_idReader));
+ /// section only if the \c _name and the \c edges_name are the same.
+ template <typename _LabelReader>
+ EdgeReader(LemonReader& _reader, const _LabelReader& _labelReader,
+ const std::string& _name = std::string())
+ : Parent(_reader), name(_name) {
+ checkConcept<_reader_bits::ItemLabelReader<Edge>, _LabelReader>();
+ edgeLabelReader.reset(new _reader_bits::
+ LabelReader<Edge, _LabelReader>(_labelReader));
}
/// \brief Destructor.
@@ -1644,11 +1647,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line start with \c \@edges,
- /// and the header line's id and the reader's id are the same.
+ /// and the header line's name and the reader's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@edges" && name == id;
}
@@ -1657,8 +1660,8 @@
///
/// It reads the content of the section.
virtual void read(std::istream& is) {
- if (!edgeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find edgeset or ID map");
+ if (!edgeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find edgeset or label map");
}
std::string line;
while (getline(is, line)) {
@@ -1667,7 +1670,7 @@
ls >> id;
typename EdgeReaders::iterator it = readers.find(id);
if (it != readers.end()) {
- it->second.read(edgeIdReader->read(ls));
+ it->second.read(edgeLabelReader->read(ls));
it->second.touch();
}
}
@@ -1683,18 +1686,18 @@
private:
- std::string id;
+ std::string name;
typedef std::map<std::string, _reader_bits::ItemStore<Edge> > EdgeReaders;
EdgeReaders readers;
- std::auto_ptr<_reader_bits::IdReaderBase<Edge> > edgeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<Edge> > edgeLabelReader;
};
/// \ingroup io_group
/// \brief SectionReader for reading labeled undirected edges.
///
/// The undirected edges section's header line is \c \@undiredges
- /// \c undiredges_id, but the \c undiredges_id may be empty.
+ /// \c undiredges_name, but the \c undiredges_name may be empty.
///
/// Each line in the section contains the name of the undirected edge
/// and then the undirected edge id.
@@ -1713,18 +1716,18 @@
/// Constructor for UndirEdgeReader. It creates the UndirEdgeReader and
/// attach it into the given LemonReader. It will use the given
/// undirected edge id reader to give back the edges. The reader will
- /// read the section only if the \c _id and the \c undiredges_id are
+ /// read the section only if the \c _name and the \c undiredges_name are
/// the same.
- template <typename _IdReader>
- UndirEdgeReader(LemonReader& _reader, const _IdReader& _idReader,
- const std::string& _id = std::string())
- : Parent(_reader), id(_id) {
- checkConcept<_reader_bits::ItemIdReader<UndirEdge>, _IdReader>();
- checkConcept<_reader_bits::ItemIdReader<Edge>, _IdReader>();
- undirEdgeIdReader.reset(new _reader_bits::
- IdReader<UndirEdge, _IdReader>(_idReader));
- edgeIdReader.reset(new _reader_bits::
- IdReader<Edge, _IdReader>(_idReader));
+ template <typename _LabelReader>
+ UndirEdgeReader(LemonReader& _reader, const _LabelReader& _labelReader,
+ const std::string& _name = std::string())
+ : Parent(_reader), name(_name) {
+ checkConcept<_reader_bits::ItemLabelReader<UndirEdge>, _LabelReader>();
+ checkConcept<_reader_bits::ItemLabelReader<Edge>, _LabelReader>();
+ undirEdgeLabelReader.reset(new _reader_bits::
+ LabelReader<UndirEdge, _LabelReader>(_labelReader));
+ edgeLabelReader.reset(new _reader_bits::
+ LabelReader<Edge, _LabelReader>(_labelReader));
}
/// \brief Destructor.
@@ -1768,11 +1771,11 @@
/// the section with the given header line.
///
/// It gives back true when the header line start with \c \@edges,
- /// and the header line's id and the reader's id are the same.
+ /// and the header line's name and the reader's name are the same.
virtual bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@undiredges" && name == id;
}
@@ -1781,11 +1784,11 @@
///
/// It reads the content of the section.
virtual void read(std::istream& is) {
- if (!edgeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find undirected edgeset or ID map");
+ if (!edgeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find undirected edgeset or label map");
}
- if (!undirEdgeIdReader->isIdReader()) {
- throw DataFormatError("Cannot find undirected edgeset or ID map");
+ if (!undirEdgeLabelReader->isLabelReader()) {
+ throw DataFormatError("Cannot find undirected edgeset or label map");
}
std::string line;
while (getline(is, line)) {
@@ -1795,14 +1798,14 @@
{
typename UndirEdgeReaders::iterator it = undirEdgeReaders.find(id);
if (it != undirEdgeReaders.end()) {
- it->second.read(undirEdgeIdReader->read(ls));
+ it->second.read(undirEdgeLabelReader->read(ls));
it->second.touch();
continue;
}
} {
typename EdgeReaders::iterator it = edgeReaders.find(id);
if (it != edgeReaders.end()) {
- it->second.read(edgeIdReader->read(ls));
+ it->second.read(edgeLabelReader->read(ls));
it->second.touch();
continue;
}
@@ -1828,24 +1831,24 @@
private:
- std::string id;
+ std::string name;
typedef std::map<std::string,
_reader_bits::ItemStore<UndirEdge> > UndirEdgeReaders;
UndirEdgeReaders undirEdgeReaders;
- std::auto_ptr<_reader_bits::IdReaderBase<UndirEdge> > undirEdgeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<UndirEdge> > undirEdgeLabelReader;
typedef std::map<std::string, _reader_bits::ItemStore<Edge> > EdgeReaders;
EdgeReaders edgeReaders;
- std::auto_ptr<_reader_bits::IdReaderBase<Edge> > edgeIdReader;
+ std::auto_ptr<_reader_bits::LabelReaderBase<Edge> > edgeLabelReader;
};
/// \ingroup io_group
/// \brief SectionReader for attributes.
///
/// The lemon format can store multiple attribute set. Each set has
- /// the header line \c \@attributes \c attributeset_id, but the
- /// attributeset_id may be empty.
+ /// the header line \c \@attributes \c attributeset_name, but the
+ /// attributeset_name may be empty.
///
/// The attributeset section contains several lines. Each of them starts
/// with an attribute and then a the value for the id.
@@ -1860,10 +1863,10 @@
///
/// Constructor for AttributeReader. It creates the AttributeReader and
/// attach it into the given LemonReader. The reader process a section
- /// only if the \c section_id and the \c _id are the same.
+ /// only if the \c section_name and the \c _name are the same.
AttributeReader(LemonReader& _reader,
- const std::string& _id = std::string())
- : Parent(_reader), id(_id) {}
+ const std::string& _name = std::string())
+ : Parent(_reader), name(_name) {}
/// \brief Destructor.
///
@@ -1916,7 +1919,7 @@
bool header(const std::string& line) {
std::istringstream ls(line);
std::string command;
- std::string name;
+ std::string id;
ls >> command >> name;
return command == "@attributes" && name == id;
}
@@ -1933,7 +1936,7 @@
typename Readers::iterator it = readers.find(id);
if (it != readers.end()) {
it->second->read(ls);
- it->second->touch();
+ it->second->touch();
}
}
for (typename Readers::iterator it = readers.begin();
@@ -1947,7 +1950,7 @@
}
private:
- std::string id;
+ std::string name;
typedef std::map<std::string, _reader_bits::ValueReaderBase*> Readers;
Readers readers;
@@ -2203,21 +2206,21 @@
private:
void readMapNames(std::istream& is, std::vector<std::string>& maps) {
- std::string line, id;
+ std::string line, name;
std::getline(is, line);
std::istringstream ls(line);
- while (ls >> id) {
- maps.push_back(id);
+ while (ls >> name) {
+ maps.push_back(name);
}
while (getline(is, line));
}
void readItemNames(std::istream& is, std::vector<std::string>& maps) {
- std::string line, id;
+ std::string line, name;
while (std::getline(is, line)) {
std::istringstream ls(line);
- ls >> id;
- maps.push_back(id);
+ ls >> name;
+ maps.push_back(name);
}
}
Modified: hugo/trunk/lemon/lemon_writer.h
==============================================================================
--- hugo/trunk/lemon/lemon_writer.h (original)
+++ hugo/trunk/lemon/lemon_writer.h Tue Jan 24 17:07:38 2006
@@ -46,21 +46,21 @@
namespace _writer_bits {
template <typename Item>
- class ItemIdWriter {
+ class ItemLabelWriter {
public:
- bool isIdWriter() { return true; }
+ bool isLabelWriter() { return true; }
- void writeId(std::ostream&, const Item&) {}
+ void writeLabel(std::ostream&, const Item&) {}
- template <class _ItemIdWriter>
+ template <class _ItemLabelWriter>
struct Constraints {
void constraints() {
- bool b = writer.isIdWriter();
+ bool b = writer.isLabelWriter();
ignore_unused_variable_warning(b);
- writer.writeId(os, item);
+ writer.writeLabel(os, item);
}
- _ItemIdWriter& writer;
+ _ItemLabelWriter& writer;
std::ostream& os;
const Item& item;
};
@@ -225,31 +225,31 @@
template <typename _Item>
- class IdWriterBase {
+ class LabelWriterBase {
public:
typedef _Item Item;
- virtual ~IdWriterBase() {}
+ virtual ~LabelWriterBase() {}
virtual void write(std::ostream&, const Item&) const = 0;
- virtual bool isIdWriter() const = 0;
+ virtual bool isLabelWriter() const = 0;
};
- template <typename _Item, typename _BoxedIdWriter>
- class IdWriter : public IdWriterBase<_Item> {
+ template <typename _Item, typename _BoxedLabelWriter>
+ class LabelWriter : public LabelWriterBase<_Item> {
public:
typedef _Item Item;
- typedef _BoxedIdWriter BoxedIdWriter;
+ typedef _BoxedLabelWriter BoxedLabelWriter;
- const BoxedIdWriter& idWriter;
+ const BoxedLabelWriter& labelWriter;
- IdWriter(const BoxedIdWriter& _idWriter)
- : idWriter(_idWriter) {}
+ LabelWriter(const BoxedLabelWriter& _labelWriter)
+ : labelWriter(_labelWriter) {}
virtual void write(std::ostream& os, const Item& item) const {
- idWriter.writeId(os, item);
+ labelWriter.writeLabel(os, item);
}
- virtual bool isIdWriter() const {
- return idWriter.isIdWriter();
+ virtual bool isLabelWriter() const {
+ return labelWriter.isLabelWriter();
}
};
@@ -374,18 +374,18 @@
/// \brief SectionWriter for writing a graph's nodeset.
///
/// The lemon format can store multiple graph nodesets with several maps.
- /// The nodeset section's header line is \c \@nodeset \c nodeset_id, but the
- /// \c nodeset_id may be empty.
+ /// The nodeset section's header line is \c \@nodeset \c nodeset_name, but
+ /// the \c 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 \c "id" named map then it will be regarded
- /// as id map. This map should contain only unique values and when the
- /// \c writeId() member will be called with a node it will write it's id.
- /// Otherwise if the \c _forceIdMap constructor parameter is true then
- /// the id map will be the id in the graph.
+ /// If the nodeset contains an \c "label" named map then it will be regarded
+ /// as label map. This map should contain only unique values and when the
+ /// \c writeLabel() member will be called with a node it will write it's
+ /// label. Otherwise if the \c _forceLabelMap constructor parameter is true
+ /// then the label map will be the id in the graph.
///
/// \relates LemonWriter
template <typename _Graph, typename _Traits = DefaultWriterTraits>
@@ -400,14 +400,14 @@
/// \brief Constructor.
///
/// Constructor for NodeSetWriter. It creates the NodeSetWriter and
- /// attach it into the given LemonWriter. If the \c _forceIdMap
- /// parameter is true then the writer will write own id map when
- /// the user does not give "id" named map.
+ /// attach it into the given LemonWriter. If the \c _forceLabelMap
+ /// parameter is true then the writer will write own label map when
+ /// the user does not give "label" named map.
NodeSetWriter(LemonWriter& _writer, const Graph& _graph,
- const std::string& _id = std::string(),
- bool _forceIdMap = true)
- : Parent(_writer), idMap(0), forceIdMap(_forceIdMap),
- graph(_graph), id(_id) {}
+ const std::string& _name = std::string(),
+ bool _forceLabelMap = true)
+ : Parent(_writer), labelMap(0), forceLabelMap(_forceLabelMap),
+ graph(_graph), name(_name) {}
/// \brief Destructor.
///
@@ -454,7 +454,7 @@
///
/// It gives back the header of the section.
virtual std::string header() {
- return "@nodeset " + id;
+ return "@nodeset " + name;
}
/// \brief Writer function of the section.
@@ -462,21 +462,21 @@
/// Write the content of the section.
virtual void write(std::ostream& os) {
for (int i = 0; i < (int)writers.size(); ++i) {
- if (writers[i].first == "id") {
- idMap = writers[i].second;
- forceIdMap = false;
+ if (writers[i].first == "label" || (writers[i].first == "id" && labelMap == 0)) {
+ labelMap = writers[i].second;
+ forceLabelMap = false;
break;
}
}
- if (forceIdMap) {
- os << "id\t";
+ if (forceLabelMap) {
+ os << "label\t";
}
for (int i = 0; i < (int)writers.size(); ++i) {
os << writers[i].first << '\t';
}
os << std::endl;
for (typename Graph::NodeIt it(graph); it != INVALID; ++it) {
- if (forceIdMap) {
+ if (forceLabelMap) {
os << graph.id(it) << '\t';
}
for (int i = 0; i < (int)writers.size(); ++i) {
@@ -489,26 +489,26 @@
public:
- /// \brief Returns true if the nodeset can write the ids of the nodes.
+ /// \brief Returns true if the nodeset can write the labels of the nodes.
///
- /// Returns true if the nodeset can write the ids of the nodes.
- /// It is possible only if an "id" named map was written or the
- /// \c _forceIdMap constructor parameter was true.
- bool isIdWriter() const {
- return idMap != 0 || forceIdMap;
+ /// Returns true if the nodeset can write the labels of the nodes.
+ /// It is possible only if an "label" named map was written or the
+ /// \c _forceLabelMap constructor parameter was true.
+ bool isLabelWriter() const {
+ return labelMap != 0 || forceLabelMap;
}
- /// \brief Write the id of the given node.
+ /// \brief Write the label of the given node.
///
- /// It writes the id of the given node. If there was written an "id"
+ /// It writes the label of the given node. If there was written an "label"
/// named map then it will write the map value belongs to the node.
- /// Otherwise if the \c forceId parameter was true it will write
- /// its id in the graph.
- void writeId(std::ostream& os, const Node& item) const {
- if (forceIdMap) {
+ /// Otherwise if the \c forceLabel parameter was true it will write
+ /// its label in the graph.
+ void writeLabel(std::ostream& os, const Node& item) const {
+ if (forceLabelMap) {
os << graph.id(item);
} else {
- idMap->write(os, item);
+ labelMap->write(os, item);
}
}
@@ -518,11 +518,11 @@
MapWriterBase<Node>*> > MapWriters;
MapWriters writers;
- _writer_bits::MapWriterBase<Node>* idMap;
- bool forceIdMap;
+ _writer_bits::MapWriterBase<Node>* labelMap;
+ bool forceLabelMap;
const Graph& graph;
- std::string id;
+ std::string name;
};
@@ -530,22 +530,22 @@
/// \brief SectionWriter for writing a graph's edgesets.
///
/// The lemon format can store multiple graph edgesets with several maps.
- /// The edgeset section's header line is \c \@edgeset \c edgeset_id, but the
- /// \c edgeset_id may be empty.
+ /// The edgeset section's header line is \c \@edgeset \c edgeset_name, but
+ /// the \c edgeset_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 edge in the edgeset. The
- /// line contains the source and the target nodes' id and the mapped
+ /// line contains the source and the target nodes' label and the mapped
/// values for each map.
///
- /// If the edgeset contains an \c "id" named map then it will be regarded
- /// as id map. This map should contain only unique values and when the
- /// \c writeId() member will be called with an edge it will write it's id.
- /// Otherwise if the \c _forceIdMap constructor parameter is true then
- /// the id map will be the id in the graph.
+ /// If the edgeset contains an \c "label" named map then it will be regarded
+ /// as label map. This map should contain only unique values and when the
+ /// \c writeLabel() member will be called with an edge it will write it's
+ /// label. Otherwise if the \c _forceLabelMap constructor parameter is true
+ /// then the label map will be the id in the graph.
///
- /// The edgeset writer needs a node id writer to identify which nodes
- /// have to be connected. If a NodeSetWriter can write the nodes' id,
+ /// The 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.
///
/// \relates LemonWriter
@@ -562,20 +562,20 @@
/// \brief Constructor.
///
/// Constructor for EdgeSetWriter. It creates the EdgeSetWriter and
- /// attach it into the given LemonWriter. It will write node ids by
- /// the \c _nodeIdWriter. If the \c _forceIdMap parameter is true
- /// then the writer will write own id map if the user does not give
- /// "id" named map.
- template <typename NodeIdWriter>
+ /// attach it into the given LemonWriter. It will write node labels by
+ /// the \c _nodeLabelWriter. If the \c _forceLabelMap parameter is true
+ /// then the writer will write own label map if the user does not give
+ /// "label" named map.
+ template <typename NodeLabelWriter>
EdgeSetWriter(LemonWriter& _writer, const Graph& _graph,
- const NodeIdWriter& _nodeIdWriter,
- const std::string& _id = std::string(),
- bool _forceIdMap = true)
- : Parent(_writer), idMap(0), forceIdMap(_forceIdMap),
- graph(_graph), id(_id) {
- checkConcept<_writer_bits::ItemIdWriter<Node>, NodeIdWriter>();
- nodeIdWriter.reset(new _writer_bits::
- IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
+ const NodeLabelWriter& _nodeLabelWriter,
+ const std::string& _name = std::string(),
+ bool _forceLabelMap = true)
+ : Parent(_writer), labelMap(0), forceLabelMap(_forceLabelMap),
+ graph(_graph), name(_name) {
+ checkConcept<_writer_bits::ItemLabelWriter<Node>, NodeLabelWriter>();
+ nodeLabelWriter.reset(new _writer_bits::
+ LabelWriter<Node, NodeLabelWriter>(_nodeLabelWriter));
}
/// \brief Destructor.
@@ -623,37 +623,37 @@
///
/// It gives back the header of the section.
virtual std::string header() {
- return "@edgeset " + id;
+ return "@edgeset " + name;
}
/// \brief Writer function of the section.
///
/// Write the content of the section.
virtual void write(std::ostream& os) {
- if (!nodeIdWriter->isIdWriter()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!nodeLabelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
for (int i = 0; i < (int)writers.size(); ++i) {
- if (writers[i].first == "id") {
- idMap = writers[i].second;
- forceIdMap = false;
+ if (writers[i].first == "label" || (writers[i].first == "id" && labelMap == 0)) {
+ labelMap = writers[i].second;
+ forceLabelMap = false;
break;
}
}
os << "\t\t";
- if (forceIdMap) {
- os << "id\t";
+ if (forceLabelMap) {
+ os << "label\t";
}
for (int i = 0; i < (int)writers.size(); ++i) {
os << writers[i].first << '\t';
}
os << std::endl;
for (typename Graph::EdgeIt it(graph); it != INVALID; ++it) {
- nodeIdWriter->write(os, graph.source(it));
+ nodeLabelWriter->write(os, graph.source(it));
os << '\t';
- nodeIdWriter->write(os, graph.target(it));
+ nodeLabelWriter->write(os, graph.target(it));
os << '\t';
- if (forceIdMap) {
+ if (forceLabelMap) {
os << graph.id(it) << '\t';
}
for (int i = 0; i < (int)writers.size(); ++i) {
@@ -666,26 +666,26 @@
public:
- /// \brief Returns true if the edgeset can write the ids of the edges.
+ /// \brief Returns true if the edgeset can write the labels of the edges.
///
- /// Returns true if the edgeset can write the ids of the edges.
- /// It is possible only if an "id" named map was written or the
- /// \c _forceIdMap constructor parameter was true.
- bool isIdWriter() const {
- return forceIdMap || idMap != 0;
+ /// Returns true if the edgeset can write the labels of the edges.
+ /// It is possible only if an "label" named map was written or the
+ /// \c _forceLabelMap constructor parameter was true.
+ bool isLabelWriter() const {
+ return forceLabelMap || labelMap != 0;
}
- /// \brief Write the id of the given edge.
+ /// \brief Write the label of the given edge.
///
- /// It writes the id of the given edge. If there was written an "id"
+ /// It writes the label of the given edge. If there was written an "label"
/// named map then it will write the map value belongs to the edge.
- /// Otherwise if the \c forceId parameter was true it will write
- /// its id in the graph.
- void writeId(std::ostream& os, const Edge& item) const {
- if (forceIdMap) {
+ /// Otherwise if the \c forceLabel parameter was true it will write
+ /// its label in the graph.
+ void writeLabel(std::ostream& os, const Edge& item) const {
+ if (forceLabelMap) {
os << graph.id(item);
} else {
- idMap->write(os, item);
+ labelMap->write(os, item);
}
}
@@ -695,13 +695,13 @@
MapWriterBase<Edge>*> > MapWriters;
MapWriters writers;
- _writer_bits::MapWriterBase<Edge>* idMap;
- bool forceIdMap;
+ _writer_bits::MapWriterBase<Edge>* labelMap;
+ bool forceLabelMap;
const Graph& graph;
- std::string id;
+ std::string name;
- std::auto_ptr<_writer_bits::IdWriterBase<Node> > nodeIdWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<Node> > nodeLabelWriter;
};
/// \ingroup io_group
@@ -709,11 +709,11 @@
///
/// The lemon format can store multiple undirected edgesets with several
/// maps. The undirected edgeset section's header line is \c \@undiredgeset
- /// \c undiredgeset_id, but the \c undiredgeset_id may be empty.
+ /// \c undiredgeset_name, but the \c undiredgeset_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' id and the mapped
+ /// 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
@@ -722,15 +722,15 @@
/// is near the same just with a prefix \c '+' or \c '-' character
/// difference.
///
- /// If the edgeset contains an \c "id" named map then it will be regarded
- /// as id map. This map should contain only unique values and when the
- /// \c writeId() member will be called with an undirected edge it will
- /// write it's id. Otherwise if the \c _forceIdMap constructor parameter
- /// is true then the id map will be the id in the graph.
+ /// If the edgeset contains an \c "label" named map then it will be regarded
+ /// as label map. This map should contain only unique values and when the
+ /// \c writeLabel() member will be called with an undirected edge it will
+ /// write it's label. Otherwise if the \c _forceLabelMap constructor
+ /// parameter is true then the label map will be the id in the graph.
///
- /// The undirected edgeset writer needs a node id writer to identify
+ /// The undirected edgeset writer needs a node label writer to identify
/// which nodes have to be connected. If a NodeSetWriter can write the
- /// nodes' id, it will be able to use with this class.
+ /// nodes' label, it will be able to use with this class.
///
/// \relates LemonWriter
template <typename _Graph, typename _Traits = DefaultWriterTraits>
@@ -747,20 +747,20 @@
/// \brief Constructor.
///
/// Constructor for UndirEdgeSetWriter. It creates the UndirEdgeSetWriter
- /// and attach it into the given LemonWriter. It will write node ids by
- /// the \c _nodeIdWriter. If the \c _forceIdMap parameter is true
- /// then the writer will write own id map if the user does not give
- /// "id" named map.
- template <typename NodeIdWriter>
+ /// and attach it into the given LemonWriter. It will write node labels by
+ /// the \c _nodeLabelWriter. If the \c _forceLabelMap parameter is true
+ /// then the writer will write own label map if the user does not give
+ /// "label" named map.
+ template <typename NodeLabelWriter>
UndirEdgeSetWriter(LemonWriter& _writer, const Graph& _graph,
- const NodeIdWriter& _nodeIdWriter,
- const std::string& _id = std::string(),
- bool _forceIdMap = true)
- : Parent(_writer), idMap(0), forceIdMap(_forceIdMap),
- graph(_graph), id(_id) {
- checkConcept<_writer_bits::ItemIdWriter<Node>, NodeIdWriter>();
- nodeIdWriter.reset(new _writer_bits::
- IdWriter<Node, NodeIdWriter>(_nodeIdWriter));
+ const NodeLabelWriter& _nodeLabelWriter,
+ const std::string& _name = std::string(),
+ bool _forceLabelMap = true)
+ : Parent(_writer), labelMap(0), forceLabelMap(_forceLabelMap),
+ graph(_graph), name(_name) {
+ checkConcept<_writer_bits::ItemLabelWriter<Node>, NodeLabelWriter>();
+ nodeLabelWriter.reset(new _writer_bits::
+ LabelWriter<Node, NodeLabelWriter>(_nodeLabelWriter));
}
/// \brief Destructor.
@@ -832,37 +832,37 @@
///
/// It gives back the header of the section.
virtual std::string header() {
- return "@undiredgeset " + id;
+ return "@undiredgeset " + name;
}
/// \brief Writer function of the section.
///
/// Write the content of the section.
virtual void write(std::ostream& os) {
- if (!nodeIdWriter->isIdWriter()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!nodeLabelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
for (int i = 0; i < (int)writers.size(); ++i) {
- if (writers[i].first == "id") {
- idMap = writers[i].second;
- forceIdMap = false;
+ if (writers[i].first == "label") {
+ labelMap = writers[i].second;
+ forceLabelMap = false;
break;
}
}
os << "\t\t";
- if (forceIdMap) {
- os << "id\t";
+ if (forceLabelMap) {
+ os << "label\t";
}
for (int i = 0; i < (int)writers.size(); ++i) {
os << writers[i].first << '\t';
}
os << std::endl;
for (typename Graph::UndirEdgeIt it(graph); it != INVALID; ++it) {
- nodeIdWriter->write(os, graph.source(it));
+ nodeLabelWriter->write(os, graph.source(it));
os << '\t';
- nodeIdWriter->write(os, graph.target(it));
+ nodeLabelWriter->write(os, graph.target(it));
os << '\t';
- if (forceIdMap) {
+ if (forceLabelMap) {
os << graph.id(it) << '\t';
}
for (int i = 0; i < (int)writers.size(); ++i) {
@@ -875,47 +875,47 @@
public:
- /// \brief Returns true if the undirected edgeset can write the ids of
+ /// \brief Returns true if the undirected edgeset can write the labels of
/// the edges.
///
- /// Returns true if the undirected edgeset can write the ids of the
- /// undirected edges. It is possible only if an "id" named map was
- /// written or the \c _forceIdMap constructor parameter was true.
- bool isIdWriter() const {
- return forceIdMap || idMap != 0;
+ /// Returns true if the undirected edgeset can write the labels of the
+ /// undirected edges. It is possible only if an "label" named map was
+ /// written or the \c _forceLabelMap constructor parameter was true.
+ bool isLabelWriter() const {
+ return forceLabelMap || labelMap != 0;
}
- /// \brief Write the id of the given undirected edge.
- ///
- /// It writes the id of the given undirected edge. If there was written
- /// an "id" named map then it will write the map value belongs to the
- /// undirected edge. Otherwise if the \c forceId parameter was true it
+ /// \brief Write the label of the given undirected edge.
+ ///
+ /// It writes the label of the given undirected edge. If there was written
+ /// an "label" named map then it will write the map value belongs to the
+ /// undirected edge. Otherwise if the \c forceLabel parameter was true it
/// will write its id in the graph.
- void writeId(std::ostream& os, const UndirEdge& item) const {
- if (forceIdMap) {
+ void writeLabel(std::ostream& os, const UndirEdge& item) const {
+ if (forceLabelMap) {
os << graph.id(item);
} else {
- idMap->write(os, item);
+ labelMap->write(os, item);
}
}
- /// \brief Write the id of the given edge.
+ /// \brief Write the label of the given edge.
///
- /// It writes the id of the given edge. If there was written
- /// an "id" named map then it will write the map value belongs to the
- /// edge. Otherwise if the \c forceId parameter was true it
+ /// It writes the label of the given edge. If there was written
+ /// an "label" named map then it will write the map value belongs to the
+ /// edge. Otherwise if the \c forceLabel parameter was true it
/// will write its id in the graph. If the edge is forward map
/// then its prefix character is \c '+' elsewhere \c '-'.
- void writeId(std::ostream& os, const Edge& item) const {
+ void writeLabel(std::ostream& os, const Edge& item) const {
if (graph.direction(item)) {
os << "+ ";
} else {
os << "- ";
}
- if (forceIdMap) {
+ if (forceLabelMap) {
os << graph.id(item);
} else {
- idMap->write(os, item);
+ labelMap->write(os, item);
}
}
@@ -925,23 +925,23 @@
MapWriterBase<UndirEdge>*> > MapWriters;
MapWriters writers;
- _writer_bits::MapWriterBase<UndirEdge>* idMap;
- bool forceIdMap;
+ _writer_bits::MapWriterBase<UndirEdge>* labelMap;
+ bool forceLabelMap;
const Graph& graph;
- std::string id;
+ std::string name;
- std::auto_ptr<_writer_bits::IdWriterBase<Node> > nodeIdWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<Node> > nodeLabelWriter;
};
/// \ingroup io_group
- /// \brief SectionWriter for writing labeled nodes.
+ /// \brief SectionWriter for writing named nodes.
///
- /// The nodes section's header line is \c \@nodes \c nodes_id, but the
- /// \c nodes_id may be empty.
+ /// The nodes section's header line is \c \@nodes \c nodes_name, but the
+ /// \c nodes_name may be empty.
///
- /// Each line in the section contains the label of the node and
- /// then the node id.
+ /// Each line in the section contains the name of the node and
+ /// then the node label.
///
/// \relates LemonWriter
template <typename _Graph>
@@ -954,14 +954,15 @@
/// \brief Constructor.
///
/// Constructor for NodeWriter. It creates the NodeWriter and
- /// attach it into the given LemonWriter. The given \c _IdWriter
- /// will write the nodes' id what can be a nodeset writer.
- template <typename _IdWriter>
- NodeWriter(LemonWriter& _writer, const _IdWriter& _idWriter,
- const std::string& _id = std::string())
- : Parent(_writer), id(_id) {
- checkConcept<_writer_bits::ItemIdWriter<Node>, _IdWriter>();
- idWriter.reset(new _writer_bits::IdWriter<Node, _IdWriter>(_idWriter));
+ /// attach it into the given LemonWriter. The given \c _LabelWriter
+ /// will write the nodes' label what can be a nodeset writer.
+ template <typename _LabelWriter>
+ NodeWriter(LemonWriter& _writer, const _LabelWriter& _labelWriter,
+ const std::string& _name = std::string())
+ : Parent(_writer), name(_name) {
+ checkConcept<_writer_bits::ItemLabelWriter<Node>, _LabelWriter>();
+ labelWriter.reset(new _writer_bits::LabelWriter<Node, _LabelWriter>
+ (_labelWriter));
}
@@ -985,45 +986,44 @@
protected:
- /// \brief Header checking function.
+ /// \brief The header of the section.
///
- /// It gives back true when the header line start with \c \@nodes,
- /// and the header line's id and the writer's id are the same.
+ /// It gives back the header of the section.
virtual std::string header() {
- return "@nodes " + id;
+ return "@nodes " + name;
}
/// \brief Writer function of the section.
///
/// Write the content of the section.
virtual void write(std::ostream& os) {
- if (!idWriter->isIdWriter()) {
- throw DataFormatError("Cannot find nodeset or ID map");
+ if (!labelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find nodeset or label map");
}
for (int i = 0; i < (int)writers.size(); ++i) {
os << writers[i].first << ' ';
- idWriter->write(os, *(writers[i].second));
+ labelWriter->write(os, *(writers[i].second));
os << std::endl;
}
}
private:
- std::string id;
+ std::string name;
typedef std::vector<std::pair<std::string, const Node*> > NodeWriters;
NodeWriters writers;
- std::auto_ptr<_writer_bits::IdWriterBase<Node> > idWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<Node> > labelWriter;
};
/// \ingroup io_group
- /// \brief SectionWriter for writing labeled edges.
+ /// \brief SectionWriter for writing named edges.
///
- /// The edges section's header line is \c \@edges \c edges_id, but the
- /// \c edges_id may be empty.
+ /// The edges section's header line is \c \@edges \c edges_name, but the
+ /// \c edges_name may be empty.
///
- /// Each line in the section contains the label of the edge and
- /// then the edge id.
+ /// Each line in the section contains the name of the edge and
+ /// then the edge label.
///
/// \relates LemonWriter
template <typename _Graph>
@@ -1036,14 +1036,14 @@
/// \brief Constructor.
///
/// Constructor for EdgeWriter. It creates the EdgeWriter and
- /// attach it into the given LemonWriter. The given \c _IdWriter
- /// will write the edges' id what can be a edgeset writer.
- template <typename _IdWriter>
- EdgeWriter(LemonWriter& _writer, const _IdWriter& _idWriter,
- const std::string& _id = std::string())
- : Parent(_writer), id(_id) {
- checkConcept<_writer_bits::ItemIdWriter<Edge>, _IdWriter>();
- idWriter.reset(new _writer_bits::IdWriter<Edge, _IdWriter>(_idWriter));
+ /// attach it into the given LemonWriter. The given \c _LabelWriter
+ /// will write the edges' label what can be a edgeset writer.
+ template <typename _LabelWriter>
+ EdgeWriter(LemonWriter& _writer, const _LabelWriter& _labelWriter,
+ const std::string& _name = std::string())
+ : Parent(_writer), name(_name) {
+ checkConcept<_writer_bits::ItemLabelWriter<Edge>, _LabelWriter>();
+ labelWriter.reset(new _writer_bits::LabelWriter<Edge, _LabelWriter>(_labelWriter));
}
/// \brief Destructor.
@@ -1065,46 +1065,45 @@
protected:
- /// \brief Header checking function.
+ /// \brief The header of the section.
///
- /// It gives back true when the header line start with \c \@edges,
- /// and the header line's id and the writer's id are the same.
+ /// It gives back the header of the section.
virtual std::string header() {
- return "@edges " + id;
+ return "@edges " + name;
}
/// \brief Writer function of the section.
///
/// Write the content of the section.
virtual void write(std::ostream& os) {
- if (!idWriter->isIdWriter()) {
- throw DataFormatError("Cannot find edgeset or ID map");
+ if (!labelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find edgeset or label map");
}
for (int i = 0; i < (int)writers.size(); ++i) {
os << writers[i].first << ' ';
- idWriter->write(os, *(writers[i].second));
+ labelWriter->write(os, *(writers[i].second));
os << std::endl;
}
}
private:
- std::string id;
+ std::string name;
typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
EdgeWriters writers;
- std::auto_ptr<_writer_bits::IdWriterBase<Edge> > idWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<Edge> > labelWriter;
};
/// \ingroup io_group
- /// \brief SectionWriter for writing labeled undirected edges.
+ /// \brief SectionWriter for writing named undirected edges.
///
/// The undirected edges section's header line is \c \@undiredges
- /// \c undiredges_id, but the \c undiredges_id may be empty.
+ /// \c undiredges_name, but the \c undiredges_name may be empty.
///
- /// Each line in the section contains the label of the undirected edge and
- /// then the undirected edge id.
+ /// Each line in the section contains the name of the undirected edge and
+ /// then the undirected edge label.
///
/// \relates LemonWriter
template <typename _Graph>
@@ -1119,19 +1118,19 @@
/// \brief Constructor.
///
/// Constructor for UndirEdgeWriter. It creates the UndirEdgeWriter and
- /// attach it into the given LemonWriter. The given \c _IdWriter
- /// will write the undirected edges' id what can be an undirected
+ /// attach it into the given LemonWriter. The given \c _LabelWriter
+ /// will write the undirected edges' label what can be an undirected
/// edgeset writer.
- template <typename _IdWriter>
- UndirEdgeWriter(LemonWriter& _writer, const _IdWriter& _idWriter,
- const std::string& _id = std::string())
- : Parent(_writer), id(_id) {
- checkConcept<_writer_bits::ItemIdWriter<Edge>, _IdWriter>();
- checkConcept<_writer_bits::ItemIdWriter<UndirEdge>, _IdWriter>();
- undirEdgeIdWriter.reset(new _writer_bits::
- IdWriter<UndirEdge, _IdWriter>(_idWriter));
- edgeIdWriter.reset(new _writer_bits::
- IdWriter<Edge, _IdWriter>(_idWriter));
+ template <typename _LabelWriter>
+ UndirEdgeWriter(LemonWriter& _writer, const _LabelWriter& _labelWriter,
+ const std::string& _name = std::string())
+ : Parent(_writer), name(_name) {
+ checkConcept<_writer_bits::ItemLabelWriter<Edge>, _LabelWriter>();
+ checkConcept<_writer_bits::ItemLabelWriter<UndirEdge>, _LabelWriter>();
+ undirEdgeLabelWriter.reset(new _writer_bits::
+ LabelWriter<UndirEdge, _LabelWriter>(_labelWriter));
+ edgeLabelWriter.reset(new _writer_bits::
+ LabelWriter<Edge, _LabelWriter>(_labelWriter));
}
/// \brief Destructor.
@@ -1160,48 +1159,47 @@
protected:
- /// \brief Header checking function.
+ /// \brief The header of the section.
///
- /// It gives back true when the header line start with \c \@undiredges,
- /// and the header line's id and the writer's id are the same.
+ /// It gives back the header of the section.
virtual std::string header() {
- return "@undiredges " + id;
+ return "@undiredges " + name;
}
/// \brief Writer function of the section.
///
/// Write the content of the section.
virtual void write(std::ostream& os) {
- if (!edgeIdWriter->isIdWriter()) {
- throw DataFormatError("Cannot find undirected edgeset or ID map");
+ if (!edgeLabelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find undirected edgeset or label map");
}
- if (!undirEdgeIdWriter->isIdWriter()) {
- throw DataFormatError("Cannot find undirected edgeset or ID map");
+ if (!undirEdgeLabelWriter->isLabelWriter()) {
+ throw DataFormatError("Cannot find undirected edgeset or label map");
}
for (int i = 0; i < (int)undirEdgeWriters.size(); ++i) {
os << undirEdgeWriters[i].first << ' ';
- undirEdgeIdWriter->write(os, *(undirEdgeWriters[i].second));
+ undirEdgeLabelWriter->write(os, *(undirEdgeWriters[i].second));
os << std::endl;
}
for (int i = 0; i < (int)edgeWriters.size(); ++i) {
os << edgeWriters[i].first << ' ';
- edgeIdWriter->write(os, *(edgeWriters[i].second));
+ edgeLabelWriter->write(os, *(edgeWriters[i].second));
os << std::endl;
}
}
private:
- std::string id;
+ std::string name;
typedef std::vector<std::pair<std::string,
const UndirEdge*> > UndirEdgeWriters;
UndirEdgeWriters undirEdgeWriters;
- std::auto_ptr<_writer_bits::IdWriterBase<UndirEdge> > undirEdgeIdWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<UndirEdge> > undirEdgeLabelWriter;
typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
EdgeWriters edgeWriters;
- std::auto_ptr<_writer_bits::IdWriterBase<Edge> > edgeIdWriter;
+ std::auto_ptr<_writer_bits::LabelWriterBase<Edge> > edgeLabelWriter;
};
@@ -1209,8 +1207,8 @@
/// \brief SectionWriter for attributes.
///
/// The lemon format can store multiple attribute set. Each set has
- /// the header line \c \@attributes \c attributeset_id, but the
- /// attributeset_id may be empty.
+ /// the header line \c \@attributes \c attributes_name, but the
+ /// attributeset_name may be empty.
///
/// The attributeset section contains several lines. Each of them starts
/// with the name of attribute and then the value.
@@ -1226,8 +1224,8 @@
/// Constructor for AttributeWriter. It creates the AttributeWriter and
/// attach it into the given LemonWriter.
AttributeWriter(LemonWriter& _writer,
- const std::string& _id = std::string())
- : Parent(_writer), id(_id) {}
+ const std::string& _name = std::string())
+ : Parent(_writer), name(_name) {}
/// \brief Destructor.
///
@@ -1248,10 +1246,10 @@
///
/// Add an attribute writer command for the writer.
template <typename Value>
- AttributeWriter& writeAttribute(const std::string& id,
+ AttributeWriter& writeAttribute(const std::string& name,
const Value& value) {
return
- writeAttribute<typename Traits::template Writer<Value> >(id, value);
+ writeAttribute<typename Traits::template Writer<Value> >(name, value);
}
/// \brief Add an attribute writer command for the writer.
@@ -1273,7 +1271,7 @@
///
/// It gives back the header of the section.
std::string header() {
- return "@attributes " + id;
+ return "@attributes " + name;
}
/// \brief Writer function of the section.
@@ -1289,7 +1287,7 @@
}
private:
- std::string id;
+ std::string name;
typedef std::vector<std::pair<std::string,
_writer_bits::ValueWriterBase*> > Writers;
Modified: hugo/trunk/test/Makefile.am
==============================================================================
--- hugo/trunk/test/Makefile.am (original)
+++ hugo/trunk/test/Makefile.am Tue Jan 24 17:07:38 2006
@@ -10,6 +10,7 @@
graph_utils_test.h \
heap_test.h
+
check_PROGRAMS = \
all_pairs_shortest_path_test \
bfs_test \
@@ -20,9 +21,9 @@
graph_adaptor_test \
graph_utils_test \
kruskal_test \
- max_matching_test \
maps_test \
matrix_maps_test \
+ max_matching_test \
min_cost_flow_test \
suurballe_test \
path_test \
Modified: hugo/trunk/test/dijkstra_test.lgf
==============================================================================
--- hugo/trunk/test/dijkstra_test.lgf (original)
+++ hugo/trunk/test/dijkstra_test.lgf Tue Jan 24 17:07:38 2006
@@ -1,5 +1,5 @@
@nodeset
-id
+label
999
998
997
@@ -1001,7 +1001,7 @@
1
0
@edgeset
- id capacity
+ label capacity
75 377 6906 27
417 515 6905 69
603 249 6904 80
More information about the Lemon-commits
mailing list