Loading...
Searching...
No Matches
GraphReader< GR > Class Template Reference
Input-Output » LEMON Graph Format

## Detailed Description

template<typename GR>
class lemon::GraphReader< GR >

This utility reads an LGF file.

It can be used almost the same way as `DigraphReader`. The only difference is that this class can handle edges and edge maps as well as arcs and arc maps.

The columns in the `@edges` (or `@arcs`) section are the edge maps. However, if there are two maps with the same name prefixed with `'+'` and `'-'`, then these can be read into an arc map. Similarly, an attribute can be read into an arc, if it's value is an edge label prefixed with `'+'` or `'-'`.

`#include <lemon/lgf_reader.h>`

## Public Member Functions

| GraphReader (GR &graph, std::istream &is=std::cin)
| Constructor.
| GraphReader (GR &graph, const std::string &fn)
| Constructor.
| GraphReader (GR &graph, const char *fn)
| Constructor.
| ~GraphReader ()
| Destructor.
Reading Rules
template<typename Map>
GraphReader & | nodeMap (const std::string &caption, Map &map)
| Node map reading rule.
template<typename Map, typename Converter>
GraphReader & | nodeMap (const std::string &caption, Map &map, const Converter &converter=Converter())
| Node map reading rule.
template<typename Map>
GraphReader & | edgeMap (const std::string &caption, Map &map)
| Edge map reading rule.
template<typename Map, typename Converter>
GraphReader & | edgeMap (const std::string &caption, Map &map, const Converter &converter=Converter())
| Edge map reading rule.
template<typename Map>
GraphReader & | arcMap (const std::string &caption, Map &map)
| Arc map reading rule.
template<typename Map, typename Converter>
GraphReader & | arcMap (const std::string &caption, Map &map, const Converter &converter=Converter())
| Arc map reading rule.
template<typename Value>
GraphReader & | attribute (const std::string &caption, Value &value)
| Attribute reading rule.
template<typename Value, typename Converter>
GraphReader & | attribute (const std::string &caption, Value &value, const Converter &converter=Converter())
| Attribute reading rule.
GraphReader & | node (const std::string &caption, Node &node)
| Node reading rule.
GraphReader & | edge (const std::string &caption, Edge &edge)
| Edge reading rule.
GraphReader & | arc (const std::string &caption, Arc &arc)
| Arc reading rule.
Select Section by Name
GraphReader & | nodes (const std::string &caption)
| Set `@nodes` section to be read.
GraphReader & | edges (const std::string &caption)
| Set `@edges` section to be read.
GraphReader & | attributes (const std::string &caption)
| Set `@attributes` section to be read.
Using Previously Constructed Node or Edge Set
template<typename Map>
GraphReader & | useNodes (const Map &map)
| Use previously constructed node set.
template<typename Map, typename Converter>
GraphReader & | useNodes (const Map &map, const Converter &converter=Converter())
| Use previously constructed node set.
template<typename Map>
GraphReader & | useEdges (const Map &map)
| Use previously constructed edge set.
template<typename Map, typename Converter>
GraphReader & | useEdges (const Map &map, const Converter &converter=Converter())
| Use previously constructed edge set.
GraphReader & | skipNodes ()
| Skip the reading of node section.
GraphReader & | skipEdges ()
| Skip the reading of edge section.
Execution of the Reader
void | run ()
| Start the batch processing.

## Related Symbols

(Note that these are not member symbols.)
template<typename TGR>
GraphReader< TGR > | graphReader (TGR &graph, std::istream &is)
| Return a GraphReader class.
template<typename TGR>
GraphReader< TGR > | graphReader (TGR &graph, const std::string &fn)
| Return a GraphReader class.
template<typename TGR>
GraphReader< TGR > | graphReader (TGR &graph, const char *fn)
| Return a GraphReader class.

## Constructor & Destructor Documentation

## GraphReader() [1/3]

template<typename GR>

GraphReader | ( | GR & | graph,
|  | std::istream & | is = std::cin )

inline

Construct an undirected graph reader, which reads from the given input stream.

## GraphReader() [2/3]

template<typename GR>

GraphReader | ( | GR & | graph,
|  | const std::string & | fn )

inline

Construct an undirected graph reader, which reads from the given file.

## GraphReader() [3/3]

template<typename GR>

GraphReader | ( | GR & | graph,
|  | const char * | fn )

inline

Construct an undirected graph reader, which reads from the given file.

## Member Function Documentation

## nodeMap() [1/2]

template<typename GR>
template<typename Map>

GraphReader & nodeMap | ( | const std::string & | caption,
|  | Map & | map )

inline

Add a node map reading rule to the reader.

## nodeMap() [2/2]

template<typename GR>
template<typename Map, typename Converter>

GraphReader & nodeMap | ( | const std::string & | caption,
|  | Map & | map,
|  | const Converter & | converter = Converter() )

inline

Add a node map reading rule with specialized converter to the reader.

## edgeMap() [1/2]

template<typename GR>
template<typename Map>

GraphReader & edgeMap | ( | const std::string & | caption,
|  | Map & | map )

inline

Add an edge map reading rule to the reader.

## edgeMap() [2/2]

template<typename GR>
template<typename Map, typename Converter>

GraphReader & edgeMap | ( | const std::string & | caption,
|  | Map & | map,
|  | const Converter & | converter = Converter() )

inline

Add an edge map reading rule with specialized converter to the reader.

## arcMap() [1/2]

template<typename GR>
template<typename Map>

GraphReader & arcMap | ( | const std::string & | caption,
|  | Map & | map )

inline

Add an arc map reading rule to the reader.

## arcMap() [2/2]

template<typename GR>
template<typename Map, typename Converter>

GraphReader & arcMap | ( | const std::string & | caption,
|  | Map & | map,
|  | const Converter & | converter = Converter() )

inline

Add an arc map reading rule with specialized converter to the reader.

## attribute() [1/2]

template<typename GR>
template<typename Value>

GraphReader & attribute | ( | const std::string & | caption,
|  | Value & | value )

inline

Add an attribute reading rule to the reader.

## attribute() [2/2]

template<typename GR>
template<typename Value, typename Converter>

GraphReader & attribute | ( | const std::string & | caption,
|  | Value & | value,
|  | const Converter & | converter = Converter() )

inline

Add an attribute reading rule with specialized converter to the reader.

## node()

template<typename GR>

GraphReader & node | ( | const std::string & | caption,
|  | Node & | node )

inline

Add a node reading rule to reader.

## edge()

template<typename GR>

GraphReader & edge | ( | const std::string & | caption,
|  | Edge & | edge )

inline

Add an edge reading rule to reader.

## arc()

template<typename GR>

GraphReader & arc | ( | const std::string & | caption,
|  | Arc & | arc )

inline

Add an arc reading rule to reader.

## nodes()

template<typename GR>

GraphReader & nodes | ( | const std::string & | caption | ) |

inline

Set `@nodes` section to be read.

## edges()

template<typename GR>

GraphReader & edges | ( | const std::string & | caption | ) |

inline

Set `@edges` section to be read.

## attributes()

template<typename GR>

GraphReader & attributes | ( | const std::string & | caption | ) |

inline

Set `@attributes` section to be read.

## useNodes() [1/2]

template<typename GR>
template<typename Map>

GraphReader & useNodes | ( | const Map & | map | ) |

inline

Use previously constructed node set, and specify the node label map.

## useNodes() [2/2]

template<typename GR>
template<typename Map, typename Converter>

GraphReader & useNodes | ( | const Map & | map,
|  | const Converter & | converter = Converter() )

inline

Use previously constructed node set, and specify the node label map and a functor which converts the label map values to `std::string`.

## useEdges() [1/2]

template<typename GR>
template<typename Map>

GraphReader & useEdges | ( | const Map & | map | ) |

inline

Use previously constructed edge set, and specify the edge label map.

## useEdges() [2/2]

template<typename GR>
template<typename Map, typename Converter>

GraphReader & useEdges | ( | const Map & | map,
|  | const Converter & | converter = Converter() )

inline

Use previously constructed edge set, and specify the edge label map and a functor which converts the label map values to `std::string`.

## skipNodes()

template<typename GR>

GraphReader & skipNodes | ( |  | ) |

inline

Omit the reading of the node section. This implies that each node map reading rule will be abandoned, and the nodes of the graph will not be constructed, which usually cause that the edge set could not be read due to lack of node name could not be read due to lack of node name resolving. Therefore `skipEdges()` function should also be used, or `useNodes()` should be used to specify the label of the nodes.

## skipEdges()

template<typename GR>

GraphReader & skipEdges | ( |  | ) |

inline

Omit the reading of the edge section. This implies that each edge map reading rule will be abandoned, and the edges of the graph will not be constructed.

## run()

template<typename GR>

void run | ( |  | ) |

inline

This function starts the batch processing

## Friends And Related Symbol Documentation

## graphReader() [1/2]

template<typename TGR>

GraphReader< TGR > graphReader | ( | TGR & | graph,
|  | const std::string & | fn )

related

This function just returns a GraphReader class.

See also
  graphReader(TGR& graph, std::istream& is)

## graphReader() [2/2]

template<typename TGR>

GraphReader< TGR > graphReader | ( | TGR & | graph,
|  | const char * | fn )

related

This function just returns a GraphReader class.

See also
  graphReader(TGR& graph, std::istream& is)