src/demo/dim_to_dot.cc
author ladanyi
Tue, 05 Apr 2005 22:37:19 +0000
changeset 1308 0274efa2222f
parent 931 9227ecd7b0bc
permissions -rw-r--r--
Applied the changes which somehow vanished during my last merge. Thanks goes
to Marci for noticing this. In detail:
- added amsmath and amssymb latex packages for latex documentation
- src/demo is also scanned for doxygen input files
marci@931
     1
// -*- c++ -*-
marci@931
     2
marci@931
     3
// Use a DIMACS max flow file as stdin.
marci@931
     4
// dim_to_dot < dimacs_max_flow_file > dot_output_file
marci@931
     5
// This program makes a dot file from a dimacs max flow file. 
marci@931
     6
// This program can be an aid in making up to date visualized documantation 
marci@931
     7
// of demo programs.
marci@931
     8
marci@931
     9
#include <iostream>
marci@931
    10
#include <fstream>
marci@931
    11
marci@931
    12
#include <lemon/smart_graph.h>
marci@931
    13
#include <lemon/dimacs.h>
marci@931
    14
marci@931
    15
using namespace lemon;
marci@931
    16
marci@931
    17
using std::cout;
marci@931
    18
using std::endl;
marci@931
    19
marci@931
    20
int main()
marci@931
    21
{    
marci@931
    22
  typedef SmartGraph Graph;
marci@931
    23
marci@931
    24
  typedef Graph::Edge Edge;
marci@931
    25
  typedef Graph::Node Node;
marci@931
    26
  typedef Graph::EdgeIt EdgeIt;
marci@931
    27
  typedef Graph::NodeIt NodeIt;
marci@931
    28
  typedef Graph::EdgeMap<int> LengthMap;
marci@931
    29
marci@931
    30
  Graph g;
marci@931
    31
  Node s, t;
marci@931
    32
  LengthMap length(g);
marci@931
    33
marci@931
    34
  readDimacs(std::cin, g, length, s, t);
marci@931
    35
marci@931
    36
  cout << "digraph lemon_dot_example {" << endl;
marci@931
    37
  cout << "  node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
marci@931
    38
  for(NodeIt n(g); n!=INVALID; ++n) {
marci@931
    39
    if (n==s) {
marci@931
    40
      cout << "  n" << g.id(n) 
marci@931
    41
	   << " [ label=\"" << g.id(n) << " (s)\" ]; " << endl;
marci@931
    42
    } else {
marci@931
    43
      if (n==t) {
marci@931
    44
	cout << "  n" << g.id(n) 
marci@931
    45
	     << " [ label=\"" << g.id(n) << " (t)\" ]; " << endl; 
marci@931
    46
      } else {
marci@931
    47
	cout << "  n" << g.id(n) 
marci@931
    48
	     << " [ label=\"" << g.id(n) << "\" ]; " << endl; 
marci@931
    49
      }
marci@931
    50
    }
marci@931
    51
  }
marci@931
    52
  cout << "  edge [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
marci@931
    53
  for(EdgeIt e(g); e!=INVALID; ++e) {
alpar@986
    54
    cout << "  n" << g.id(g.source(e)) << " -> " << " n" << g.id(g.target(e))
marci@931
    55
	 << " [ label=\"" << g.id(e) 
marci@931
    56
	 << ", length:" << length[e] << "\" ]; " << endl;
marci@931
    57
  } 
marci@931
    58
  cout << "}" << endl;
marci@931
    59
}