Loading...
Searching...
No Matches
LEMON Graph Format
Input-Output

## Detailed Description

This group contains methods for reading and writing LEMON Graph Format.

## Classes

class | DigraphReader< DGR >
| LGF reader for directed graphs More...
class | GraphReader< GR >
| LGF reader for undirected graphs More...
class | BpGraphReader< BGR >
| LGF reader for bipartite graphs More...
class | SectionReader
| Section reader class. More...
class | LgfContents
| Reader for the contents of the LGF file. More...
class | DigraphWriter< DGR >
| LGF writer for directed graphs More...
class | GraphWriter< GR >
| LGF writer for undirected graphs More...
class | BpGraphWriter< BGR >
| LGF writer for undirected bipartite graphs More...
class | SectionWriter
| Section writer class. More...

## Files

file | lgf_reader.h
file | lgf_writer.h

## Functions

template<typename TDGR>
DigraphReader< TDGR > | digraphReader (TDGR &digraph, std::istream &is)
| Return a DigraphReader class.
template<typename TGR>
GraphReader< TGR > | graphReader (TGR &graph, std::istream &is)
| Return a GraphReader class.
template<typename TBGR>
BpGraphReader< TBGR > | bpGraphReader (TBGR &graph, std::istream &is)
| Return a BpGraphReader class.
SectionReader | sectionReader (std::istream &is)
| Return a SectionReader class.
template<typename TDGR>
DigraphWriter< TDGR > | digraphWriter (const TDGR &digraph, std::ostream &os)
| Return a DigraphWriter class.
template<typename TGR>
GraphWriter< TGR > | graphWriter (const TGR &graph, std::ostream &os)
| Return a GraphWriter class.
template<typename TBGR>
BpGraphWriter< TBGR > | bpGraphWriter (const TBGR &graph, std::ostream &os)
| Return a BpGraphWriter class.
SectionWriter | sectionWriter (std::ostream &os)
| Return a SectionWriter class.

## Function Documentation

## digraphReader()

template<typename TDGR>

DigraphReader< TDGR > digraphReader | ( | TDGR & | digraph,
|  | std::istream & | is )

related

This function just returns a DigraphReader class.

With this function a digraph can be read from an LGF file or input stream with several maps and attributes. For example, there is network flow problem on a digraph, i.e. a digraph with a capacity map on the arcs and source and target nodes. This digraph can be read with the following code:

ListDigraph digraph;
ListDigraph::ArcMap<int> cm(digraph);
ListDigraph::Node src, trg;
digraphReader(digraph, std::cin).
arcMap("capacity", cap).
node("source", src).
node("target", trg).
run();
lemon::DigraphReader::run
void run()
Start the batch processing.
Definition lgf_reader.h:1164
lemon::DigraphReader::arcMap
DigraphReader & arcMap(const std::string &caption, Map &map)
Arc map reading rule.
Definition lgf_reader.h:661
lemon::DigraphReader::node
DigraphReader & node(const std::string &caption, Node &node)
Node reading rule.
Definition lgf_reader.h:710
lemon::ListDigraph
A general directed graph structure.
Definition list_graph.h:331

For a complete documentation, please see the DigraphReader class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  digraphReader(TDGR& digraph, const std::string& fn)
  digraphReader(TDGR& digraph, const char* fn)

## graphReader()

template<typename TGR>

GraphReader< TGR > graphReader | ( | TGR & | graph,
|  | std::istream & | is )

related

This function just returns a GraphReader class.

With this function a graph can be read from an LGF file or input stream with several maps and attributes. For example, there is weighted matching problem on a graph, i.e. a graph with a weight map on the edges. This graph can be read with the following code:

ListGraph graph;
ListGraph::EdgeMap<int> weight(graph);
graphReader(graph, std::cin).
edgeMap("weight", weight).
run();
lemon::GraphReader::run
void run()
Start the batch processing.
Definition lgf_reader.h:2043
lemon::GraphReader::edgeMap
GraphReader & edgeMap(const std::string &caption, Map &map)
Edge map reading rule.
Definition lgf_reader.h:1493
lemon::ListGraph
A general undirected graph structure.
Definition list_graph.h:1196

For a complete documentation, please see the GraphReader class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  graphReader(TGR& graph, const std::string& fn)
  graphReader(TGR& graph, const char* fn)

## bpGraphReader()

template<typename TBGR>

BpGraphReader< TBGR > bpGraphReader | ( | TBGR & | graph,
|  | std::istream & | is )

related

This function just returns a BpGraphReader class.

With this function a graph can be read from an LGF file or input stream with several maps and attributes. For example, there is bipartite weighted matching problem on a graph, i.e. a graph with a weight map on the edges. This graph can be read with the following code:

ListBpGraph graph;
ListBpGraph::EdgeMap<int> weight(graph);
bpGraphReader(graph, std::cin).
edgeMap("weight", weight).
run();
lemon::BpGraphReader::run
void run()
Start the batch processing.
Definition lgf_reader.h:3100
lemon::BpGraphReader::edgeMap
BpGraphReader & edgeMap(const std::string &caption, Map &map)
Edge map reading rule.
Definition lgf_reader.h:2433
lemon::ListBpGraph
A general undirected graph structure.
Definition list_graph.h:2123

For a complete documentation, please see the BpGraphReader class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  bpGraphReader(TBGR& graph, const std::string& fn)
  bpGraphReader(TBGR& graph, const char* fn)

## sectionReader()

SectionReader sectionReader | ( | std::istream & | is | ) |

related

This function just returns a SectionReader class.

Please see SectionReader documentation about the custom section input.

See also
  sectionReader(const std::string& fn)
  sectionReader(const char *fn)

## digraphWriter()

template<typename TDGR>

DigraphWriter< TDGR > digraphWriter | ( | const TDGR & | digraph,
|  | std::ostream & | os )

related

This function just returns a DigraphWriter class.

With this function a digraph can be write to a file or output stream in LGF format with several maps and attributes. For example, with the following code a network flow problem can be written to the standard output, i.e. a digraph with a capacity map on the arcs and source and target nodes:

ListDigraph digraph;
ListDigraph::ArcMap<int> cap(digraph);
ListDigraph::Node src, trg;
// Setting the capacity map and source and target nodes
digraphWriter(digraph, std::cout).
arcMap("capacity", cap).
node("source", src).
node("target", trg).
run();
lemon::DigraphWriter::run
void run()
Start the batch processing.
Definition lgf_writer.h:921
lemon::DigraphWriter::node
DigraphWriter & node(const std::string &caption, const Node &node)
Node writing rule.
Definition lgf_writer.h:650
lemon::DigraphWriter::arcMap
DigraphWriter & arcMap(const std::string &caption, const Map &map)
Arc map writing rule.
Definition lgf_writer.h:601

For a complete documentation, please see the DigraphWriter class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  digraphWriter(const TDGR& digraph, const std::string& fn)
  digraphWriter(const TDGR& digraph, const char* fn)

## graphWriter()

template<typename TGR>

GraphWriter< TGR > graphWriter | ( | const TGR & | graph,
|  | std::ostream & | os )

related

This function just returns a GraphWriter class.

With this function a graph can be write to a file or output stream in LGF format with several maps and attributes. For example, with the following code a weighted matching problem can be written to the standard output, i.e. a graph with a weight map on the edges:

ListGraph graph;
ListGraph::EdgeMap<int> weight(graph);
// Setting the weight map
graphWriter(graph, std::cout).
edgeMap("weight", weight).
run();
lemon::GraphWriter::run
void run()
Start the batch processing.
Definition lgf_writer.h:1562
lemon::GraphWriter::edgeMap
GraphWriter & edgeMap(const std::string &caption, const Map &map)
Edge map writing rule.
Definition lgf_writer.h:1196

For a complete documentation, please see the GraphWriter class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  graphWriter(const TGR& graph, const std::string& fn)
  graphWriter(const TGR& graph, const char* fn)

## bpGraphWriter()

template<typename TBGR>

BpGraphWriter< TBGR > bpGraphWriter | ( | const TBGR & | graph,
|  | std::ostream & | os )

related

This function just returns a BpGraphWriter class.

With this function a bipartite graph can be write to a file or output stream in LGF format with several maps and attributes. For example, with the following code a bipartite weighted matching problem can be written to the standard output, i.e. a graph with a weight map on the edges:

ListBpGraph graph;
ListBpGraph::EdgeMap<int> weight(graph);
// Setting the weight map
bpGraphWriter(graph, std::cout).
edgeMap("weight", weight).
run();
lemon::BpGraphWriter::run
void run()
Start the batch processing.
Definition lgf_writer.h:2379
lemon::BpGraphWriter::edgeMap
BpGraphWriter & edgeMap(const std::string &caption, const Map &map)
Edge map writing rule.
Definition lgf_writer.h:1901

For a complete documentation, please see the BpGraphWriter class documentation.

Warning
  Don't forget to put the run() to the end of the parameter list.

See also
  bpGraphWriter(const TBGR& graph, const std::string& fn)
  bpGraphWriter(const TBGR& graph, const char* fn)

## sectionWriter()

SectionWriter sectionWriter | ( | std::ostream & | os | ) |

related

This function just returns a SectionWriter class.

Please see SectionWriter documentation about the custom section output.

See also
  sectionWriter(const std::string& fn)
  sectionWriter(const char *fn)