BpUGraphReader
class provides the graph input. Before you read this documentation it might be useful to read the general description of Graph Input-Output.The given file format may contain several maps and labeled nodes or edges.
If you read a graph you need not read all the maps and items just those that you need. The interface of the BpUGraphReader
is very similar to the BpUGraphWriter but the reading method does not depend on the order of the given commands.
The reader object suppose that each not read value does not contain whitespaces, therefore it has some extra possibilities to control how it should skip the values when the string representation contains spaces.
BpUGraphReader<ListBpUGraph> reader(std::cin, graph);
The readANodeMap()
function reads a map from the A-part of the@bpnodeset
section, while the readBNodeMap()
reads from the B-part of the section. If you use the readNodeMap()
function, then the given map should appear in both part of the section. If there is a map that you do not want to read from the file and there is whitespace in the string represenation of the values then you should call the skipANodeMap()
, skipBNodeMap()
or skipNodeMap()
template member function with proper parameters.
reader.readNodeMap("coords", coords); reader.readANodeMap("range", range); reader.readANodeMap("benefit", benefit); reader.skipNodeMap("description", desc); reader.readNodeMap("color", colorMap);
With the readUEdgeMap()
member function you can give an uedge map reading command similar to the NodeMaps.
reader.readUEdgeMap("capacity", capacityMap); reader.readEdgeMap("flow", flowMap);
With readNode()
and readUEdge()
functions you can read labeled Nodes and UEdges.
reader.readNode("source", sourceNode); reader.readNode("target", targetNode); reader.readUEdge("observed", uEdge);
With the readAttribute()
functions you can read an attribute in a variable. You can specify the reader for the attribute as the nodemaps.
After you give all read commands you must call the run()
member function, which execute all the commands.
reader.run();
#include <lemon/graph_reader.h>
Public Member Functions | |
BpUGraphReader (std::istream &_is, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper()) | |
Construct a new BpUGraphReader. | |
BpUGraphReader (const std::string &_filename, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper()) | |
Construct a new BpUGraphReader. | |
BpUGraphReader (LemonReader &_reader, Graph &_graph, const DefaultSkipper &_skipper=DefaultSkipper()) | |
Construct a new BpUGraphReader. | |
~BpUGraphReader () | |
template<typename Map > | |
BpUGraphReader & | readNodeMap (std::string name, Map &map) |
template<typename ItemReader , typename Map > | |
BpUGraphReader & | readNodeMap (std::string name, Map &map, const ItemReader &ir=ItemReader()) |
template<typename ItemReader > | |
BpUGraphReader & | skipNodeMap (std::string name, const ItemReader &ir=ItemReader()) |
template<typename Map > | |
BpUGraphReader & | readANodeMap (std::string name, Map &map) |
template<typename ItemReader , typename Map > | |
BpUGraphReader & | readANodeMap (std::string name, Map &map, const ItemReader &ir=ItemReader()) |
template<typename ItemReader > | |
BpUGraphReader & | skipANodeMap (std::string name, const ItemReader &ir=ItemReader()) |
template<typename Map > | |
BpUGraphReader & | readBNodeMap (std::string name, Map &map) |
template<typename ItemReader , typename Map > | |
BpUGraphReader & | readBNodeMap (std::string name, Map &map, const ItemReader &ir=ItemReader()) |
template<typename ItemReader > | |
BpUGraphReader & | skipBNodeMap (std::string name, const ItemReader &ir=ItemReader()) |
template<typename Map > | |
BpUGraphReader & | readUEdgeMap (std::string name, Map &map) |
template<typename ItemReader , typename Map > | |
BpUGraphReader & | readUEdgeMap (std::string name, Map &map, const ItemReader &ir=ItemReader()) |
template<typename ItemReader > | |
BpUGraphReader & | skipUEdgeMap (std::string name, const ItemReader &ir=ItemReader()) |
template<typename Map > | |
BpUGraphReader & | readEdgeMap (std::string name, Map &map) |
template<typename ItemReader , typename Map > | |
BpUGraphReader & | readEdgeMap (std::string name, Map &map, const ItemReader &ir=ItemReader()) |
template<typename ItemReader > | |
BpUGraphReader & | skipEdgeMap (std::string name, const ItemReader &ir=ItemReader()) |
BpUGraphReader & | readNode (std::string name, Node &node) |
BpUGraphReader & | readEdge (std::string name, Edge &edge) |
BpUGraphReader & | readUEdge (std::string name, UEdge &edge) |
template<typename Value > | |
BpUGraphReader & | readAttribute (std::string name, Value &value) |
template<typename ItemReader , typename Value > | |
BpUGraphReader & | readAttribute (std::string name, Value &value, const ItemReader &ir=ItemReader()) |
operator LemonReader & () | |
Conversion operator to LemonReader. | |
void | run () |
bool | isLabelReader () const |
void | readLabel (std::istream &is, Node &node) const |
Gives back the node by its label. | |
void | readLabel (std::istream &is, Edge &edge) const |
Gives back the edge by its label. | |
void | readLabel (std::istream &is, UEdge &uedge) const |
Gives back the undirected edge by its label. |
BpUGraphReader | ( | std::istream & | _is, | |
Graph & | _graph, | |||
const DefaultSkipper & | _skipper = DefaultSkipper() | |||
) | [inline] |
Construct a new BpUGraphReader. It reads into the given graph and it use the given reader as the default skipper.
BpUGraphReader | ( | const std::string & | _filename, | |
Graph & | _graph, | |||
const DefaultSkipper & | _skipper = DefaultSkipper() | |||
) | [inline] |
Construct a new BpUGraphReader. It reads into the given graph and it use the given reader as the default skipper.
BpUGraphReader | ( | LemonReader & | _reader, | |
Graph & | _graph, | |||
const DefaultSkipper & | _skipper = DefaultSkipper() | |||
) | [inline] |
Construct a new BpUGraphReader. It reads into the given graph and it use the given reader as the default skipper.
~BpUGraphReader | ( | ) | [inline] |
Destruct the graph reader.
BpUGraphReader& readNodeMap | ( | std::string | name, | |
Map & | map | |||
) | [inline] |
Give a new node map reading command to the reader.
BpUGraphReader& readNodeMap | ( | std::string | name, | |
Map & | map, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new node map reading command to the reader.
BpUGraphReader& skipNodeMap | ( | std::string | name, | |
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new node map skipping command to the reader.
BpUGraphReader& readANodeMap | ( | std::string | name, | |
Map & | map | |||
) | [inline] |
Give a new A-node map reading command to the reader.
BpUGraphReader& readANodeMap | ( | std::string | name, | |
Map & | map, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new A-node map reading command to the reader.
BpUGraphReader& skipANodeMap | ( | std::string | name, | |
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new A-node map skipping command to the reader.
BpUGraphReader& readBNodeMap | ( | std::string | name, | |
Map & | map | |||
) | [inline] |
Give a new B-node map reading command to the reader.
BpUGraphReader& readBNodeMap | ( | std::string | name, | |
Map & | map, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new B-node map reading command to the reader.
BpUGraphReader& skipBNodeMap | ( | std::string | name, | |
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new B-node map skipping command to the reader.
BpUGraphReader& readUEdgeMap | ( | std::string | name, | |
Map & | map | |||
) | [inline] |
Give a new undirected edge map reading command to the reader.
BpUGraphReader& readUEdgeMap | ( | std::string | name, | |
Map & | map, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new undirected edge map reading command to the reader.
BpUGraphReader& skipUEdgeMap | ( | std::string | name, | |
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new undirected edge map skipping command to the reader.
BpUGraphReader& readEdgeMap | ( | std::string | name, | |
Map & | map | |||
) | [inline] |
Give a new edge map reading command to the reader.
BpUGraphReader& readEdgeMap | ( | std::string | name, | |
Map & | map, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new edge map reading command to the reader.
BpUGraphReader& skipEdgeMap | ( | std::string | name, | |
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new edge map skipping command to the reader.
BpUGraphReader& readNode | ( | std::string | name, | |
Node & | node | |||
) | [inline] |
Give a new labeled node reading command to the reader.
BpUGraphReader& readEdge | ( | std::string | name, | |
Edge & | edge | |||
) | [inline] |
Give a new labeled edge reading command to the reader.
BpUGraphReader& readUEdge | ( | std::string | name, | |
UEdge & | edge | |||
) | [inline] |
Give a new labeled undirected edge reading command to the reader.
BpUGraphReader& readAttribute | ( | std::string | name, | |
Value & | value | |||
) | [inline] |
Give a new attribute reading command.
BpUGraphReader& readAttribute | ( | std::string | name, | |
Value & | value, | |||
const ItemReader & | ir = ItemReader() | |||
) | [inline] |
Give a new attribute reading command.
operator LemonReader & | ( | ) | [inline] |
Conversion operator to LemonReader. It make possible to access the encapsulated LemonReader, this way you can attach to this reader new instances of LemonReader::SectionReader.
void run | ( | ) | [inline] |
Executes the reading commands.
bool isLabelReader | ( | ) | const [inline] |
Returns true if the reader can give back the items by its label.
void readLabel | ( | std::istream & | is, | |
Node & | node | |||
) | const [inline] |
It reads an label from the stream and gives back which node belongs to it. It is possible only if there was read a "label" named node map.
void readLabel | ( | std::istream & | is, | |
Edge & | edge | |||
) | const [inline] |
It reads an label from the stream and gives back which edge belongs to it. It is possible only if there was read a "label" named edge map.
void readLabel | ( | std::istream & | is, | |
UEdge & | uedge | |||
) | const [inline] |
It reads an label from the stream and gives back which undirected edge belongs to it. It is possible only if there was read a "label" named edge map.