marci@931: // -*- c++ -*-
marci@931: 
marci@931: // Use a DIMACS max flow file as stdin.
marci@931: // dim_to_dot < dimacs_max_flow_file > dot_output_file
marci@931: // This program makes a dot file from a dimacs max flow file. 
marci@931: // This program can be an aid in making up to date visualized documantation 
marci@931: // of demo programs.
marci@931: 
marci@931: #include <iostream>
marci@931: #include <fstream>
marci@931: 
marci@931: #include <lemon/smart_graph.h>
marci@931: #include <lemon/dimacs.h>
marci@931: 
marci@931: using namespace lemon;
marci@931: 
marci@931: using std::cout;
marci@931: using std::endl;
marci@931: 
marci@931: int main()
marci@931: {    
marci@931:   typedef SmartGraph Graph;
marci@931: 
marci@931:   typedef Graph::Edge Edge;
marci@931:   typedef Graph::Node Node;
marci@931:   typedef Graph::EdgeIt EdgeIt;
marci@931:   typedef Graph::NodeIt NodeIt;
marci@931:   typedef Graph::EdgeMap<int> LengthMap;
marci@931: 
marci@931:   Graph g;
marci@931:   Node s, t;
marci@931:   LengthMap length(g);
marci@931: 
marci@931:   readDimacs(std::cin, g, length, s, t);
marci@931: 
marci@931:   cout << "digraph lemon_dot_example {" << endl;
marci@931:   cout << "  node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
marci@931:   for(NodeIt n(g); n!=INVALID; ++n) {
marci@931:     if (n==s) {
marci@931:       cout << "  n" << g.id(n) 
marci@931: 	   << " [ label=\"" << g.id(n) << " (s)\" ]; " << endl;
marci@931:     } else {
marci@931:       if (n==t) {
marci@931: 	cout << "  n" << g.id(n) 
marci@931: 	     << " [ label=\"" << g.id(n) << " (t)\" ]; " << endl; 
marci@931:       } else {
marci@931: 	cout << "  n" << g.id(n) 
marci@931: 	     << " [ label=\"" << g.id(n) << "\" ]; " << endl; 
marci@931:       }
marci@931:     }
marci@931:   }
marci@931:   cout << "  edge [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
marci@931:   for(EdgeIt e(g); e!=INVALID; ++e) {
alpar@986:     cout << "  n" << g.id(g.source(e)) << " -> " << " n" << g.id(g.target(e))
marci@931: 	 << " [ label=\"" << g.id(e) 
marci@931: 	 << ", length:" << length[e] << "\" ]; " << endl;
marci@931:   } 
marci@931:   cout << "}" << endl;
marci@931: }