COIN-OR::LEMON - Graph Library

Ticket #81: lgf_demo_merge_abc5b9d0c67e.patch

File lgf_demo_merge_abc5b9d0c67e.patch, 2.3 KB (added by Peter Kovacs, 16 years ago)

lgf_demo.cc is merged with reader_writer_demo.cc [abc5b9d0c67e]

  • demo/lgf_demo.cc

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1215271348 -7200
    # Node ID abc5b9d0c67e684c8cfafa55f2edd218f54b82a2
    # Parent  1e6af6f0843c373a0579fc699ac4a83bb4f5948a
    lgf_demo.cc is merged with reader_writer_demo.cc (from SVN -r3501)
    
    diff -r 1e6af6f0843c -r abc5b9d0c67e demo/lgf_demo.cc
    a b  
    2020///\file
    2121///\brief Demonstrating graph input and output
    2222///
    23 /// This program gives an example of how to load a directed graph from
    24 /// an \ref lgf-format "LGF" file with the \ref lemon::DigraphReader
    25 /// "DigraphReader" class.
     23/// This program gives an example of how to read and write a digraph
     24/// and additional maps from/to a stream or a file using the
     25/// \ref lgf-format "LGF" format.
    2626///
    2727/// The \c "digraph.lgf" file:
    2828/// \include digraph.lgf
    2929///
    30 /// And the program which reads it:
     30/// And the program which reads it and prints the digraph to the
     31/// standard output:
    3132/// \include lgf_demo.cc
    3233
    3334#include <iostream>
    3435#include <lemon/smart_graph.h>
    3536#include <lemon/lgf_reader.h>
    3637#include <lemon/lgf_writer.h>
    37 #include <lemon/random.h>
    38 
    3938
    4039using namespace lemon;
    4140
     
    4342  SmartDigraph g;
    4443  SmartDigraph::ArcMap<int> cap(g);
    4544  SmartDigraph::Node s, t;
     45 
     46  try {
     47    digraphReader("digraph.lgf", g). // read the directed graph into g
     48      arcMap("capacity", cap).       // read the 'capacity' arc map into cap
     49      node("source", s).             // read 'source' node to s
     50      node("target", t).             // read 'target' node to t
     51      run();
     52  } catch (DataFormatError& error) { // check if there was any error
     53    std::cerr << "Error: " << error.what() << std::endl;
     54    return -1;
     55  }
    4656
    47   digraphReader("digraph.lgf", g). // read the directeg graph into g
    48     arcMap("capacity", cap).       // read the 'capacity' arc map into cap
    49     node("source", s).             // read 'source' node to s
    50     node("target", t).             // read 'target' node to t
    51     run();
    52 
    53   std::cout << "Digraph read from 'digraph.lgf'" << std::endl;
     57  std::cout << "A digraph is read from 'digraph.lgf'." << std::endl;
    5458  std::cout << "Number of nodes: " << countNodes(g) << std::endl;
    5559  std::cout << "Number of arcs: " << countArcs(g) << std::endl;
    5660