demo/dim_to_dot.cc
changeset 1577 15098fb5275c
parent 1435 8e85e6bbefdf
child 1636 260ac104190f
equal deleted inserted replaced
0:2643bbe1bc87 1:fe3bc8eac5e4
     3 // Use a DIMACS max flow file as stdin.
     3 // Use a DIMACS max flow file as stdin.
     4 // dim_to_dot < dimacs_max_flow_file > dot_output_file
     4 // dim_to_dot < dimacs_max_flow_file > dot_output_file
     5 // This program makes a dot file from a dimacs max flow file. 
     5 // This program makes a dot file from a dimacs max flow file. 
     6 // This program can be an aid in making up to date visualized documantation 
     6 // This program can be an aid in making up to date visualized documantation 
     7 // of demo programs.
     7 // of demo programs.
       
     8 
       
     9 // For later documentation (if marci does not do it)
       
    10 // Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag.
       
    11 // Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem
       
    12 // kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A
       
    13 // doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a
       
    14 // doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van
       
    15 // a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit
       
    16 // valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff.
       
    17 
     8 
    18 
     9 #include <iostream>
    19 #include <iostream>
    10 #include <fstream>
    20 #include <fstream>
    11 
    21 
    12 #include <lemon/smart_graph.h>
    22 #include <lemon/smart_graph.h>
    15 using namespace lemon;
    25 using namespace lemon;
    16 
    26 
    17 using std::cout;
    27 using std::cout;
    18 using std::endl;
    28 using std::endl;
    19 
    29 
    20 int main()
    30 int main(int argc, char *argv[]) 
    21 {    
    31 {
       
    32   if(argc<2)
       
    33   {
       
    34       std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
       
    35       std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
       
    36       return 0;
       
    37   }
       
    38 
       
    39 
       
    40   //input stream to read the graph from
       
    41   std::ifstream is(argv[1]);
       
    42 
    22   typedef SmartGraph Graph;
    43   typedef SmartGraph Graph;
    23 
    44 
    24   typedef Graph::Edge Edge;
    45   typedef Graph::Edge Edge;
    25   typedef Graph::Node Node;
    46   typedef Graph::Node Node;
    26   typedef Graph::EdgeIt EdgeIt;
    47   typedef Graph::EdgeIt EdgeIt;
    29 
    50 
    30   Graph g;
    51   Graph g;
    31   Node s, t;
    52   Node s, t;
    32   LengthMap length(g);
    53   LengthMap length(g);
    33 
    54 
    34   readDimacs(std::cin, g, length, s, t);
    55   readDimacs(is, g, length, s, t);
    35 
    56 
    36   cout << "digraph lemon_dot_example {" << endl;
    57   cout << "digraph lemon_dot_example {" << endl;
    37   cout << "  node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
    58   cout << "  node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
    38   for(NodeIt n(g); n!=INVALID; ++n) {
    59   for(NodeIt n(g); n!=INVALID; ++n) {
    39     if (n==s) {
    60     if (n==s) {