Loading...
Searching...
No Matches
LgfContents Class Reference
Input-Output » LEMON Graph Format

## Detailed Description

This class can be used to read the sections, the map names and the attributes from a file. Usually, the LEMON programs know that, which type of graph, which maps and which attributes should be read from a file, but in general tools (like glemon) the contents of an LGF file should be guessed somehow. This class reads the graph and stores the appropriate information for reading the graph.

LgfContents contents("graph.lgf");
contents.run();
// Does it contain any node section and arc section?
if (contents.nodeSectionNum() == 0 || contents.arcSectionNum()) {
std::cerr << "Failure, cannot find graph." << std::endl;
return -1;
}
std::cout << "The name of the default node section: "
<< contents.nodeSection(0) << std::endl;
std::cout << "The number of the arc maps: "
<< contents.arcMaps(0).size() << std::endl;
std::cout << "The name of second arc map: "
<< contents.arcMaps(0)[1] << std::endl;
lemon::LgfContents::LgfContents
LgfContents(std::istream &is)
Constructor.
Definition lgf_reader.h:3581

`#include <lemon/lgf_reader.h>`

## Public Member Functions

| LgfContents (std::istream &is)
| Constructor.
| LgfContents (const std::string &fn)
| Constructor.
| LgfContents (const char *fn)
| Constructor.
| ~LgfContents ()
| Destructor.
Node Sections
int | nodeSectionNum () const
| Gives back the number of node sections in the file.
const std::string & | nodeSection (int i) const
| Returns the node section name at the given position.
const std::vector< std::string > & | nodeMapNames (int i) const
| Gives back the node maps for the given section.
Arc/Edge Sections
int | arcSectionNum () const
| Gives back the number of arc/edge sections in the file.
const std::string & | arcSection (int i) const
| Returns the arc/edge section name at the given position.
const std::vector< std::string > & | arcMapNames (int i) const
| Gives back the arc/edge maps for the given section.
Synonyms
int | edgeSectionNum () const
| Gives back the number of arc/edge sections in the file.
const std::string & | edgeSection (int i) const
| Returns the section name at the given position.
const std::vector< std::string > & | edgeMapNames (int i) const
| Gives back the edge maps for the given section.
Attribute Sections
int | attributeSectionNum () const
| Gives back the number of attribute sections in the file.
const std::string & | attributeSectionNames (int i) const
| Returns the attribute section name at the given position.
const std::vector< std::string > & | attributes (int i) const
| Gives back the attributes for the given section.
Extra Sections
int | extraSectionNum () const
| Gives back the number of extra sections in the file.
const std::string & | extraSection (int i) const
| Returns the extra section type at the given position.
Execution of the Contents Reader
void | run ()
| Starts the reading.

## Constructor & Destructor Documentation

## LgfContents() [1/3]

LgfContents | ( | std::istream & | is | ) |

inline

Construct an LGF contents reader, which reads from the given input stream.

## LgfContents() [2/3]

LgfContents | ( | const std::string & | fn | ) |

inline

Construct an LGF contents reader, which reads from the given file.

## LgfContents() [3/3]

LgfContents | ( | const char * | fn | ) |

inline

Construct an LGF contents reader, which reads from the given file.

## Member Function Documentation

## nodeSectionNum()

int nodeSectionNum | ( |  | ) | const

inline

Gives back the number of node sections in the file.

## nodeSection()

const std::string & nodeSection | ( | int | i | ) | const

inline

Returns the node section name at the given position.

## nodeMapNames()

const std::vector< std::string > & nodeMapNames | ( | int | i | ) | const

inline

Gives back the node maps for the given section.

## arcSectionNum()

int arcSectionNum | ( |  | ) | const

inline

Gives back the number of arc/edge sections in the file.

Note
  It is synonym of `edgeSectionNum()`.

## arcSection()

const std::string & arcSection | ( | int | i | ) | const

inline

Returns the arc/edge section name at the given position.

Note
  It is synonym of `edgeSection()`.

## arcMapNames()

const std::vector< std::string > & arcMapNames | ( | int | i | ) | const

inline

Gives back the arc/edge maps for the given section.

Note
  It is synonym of `edgeMapNames()`.

## edgeSectionNum()

int edgeSectionNum | ( |  | ) | const

inline

Gives back the number of arc/edge sections in the file.

Note
  It is synonym of `arcSectionNum()`.

## edgeSection()

const std::string & edgeSection | ( | int | i | ) | const

inline

Returns the section name at the given position.

Note
  It is synonym of `arcSection()`.

## edgeMapNames()

const std::vector< std::string > & edgeMapNames | ( | int | i | ) | const

inline

Gives back the edge maps for the given section.

Note
  It is synonym of `arcMapNames()`.

## attributeSectionNum()

int attributeSectionNum | ( |  | ) | const

inline

Gives back the number of attribute sections in the file.

## attributeSectionNames()

const std::string & attributeSectionNames | ( | int | i | ) | const

inline

Returns the attribute section name at the given position.

## attributes()

const std::vector< std::string > & attributes | ( | int | i | ) | const

inline

Gives back the attributes for the given section.

## extraSectionNum()

int extraSectionNum | ( |  | ) | const

inline

Gives back the number of extra sections in the file.

## extraSection()

const std::string & extraSection | ( | int | i | ) | const

inline

Returns the section type at the given position.

## run()

void run | ( |  | ) |

inline

This function starts the reading.