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: athos@1577: // For later documentation (if marci does not do it) athos@1577: // Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag. athos@1577: // Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem athos@1577: // kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A athos@1577: // doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a athos@1577: // doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van athos@1577: // a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit athos@1577: // valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff. athos@1577: athos@1577: marci@931: #include marci@931: #include marci@931: marci@931: #include marci@931: #include marci@931: marci@931: using namespace lemon; marci@931: marci@931: using std::cout; marci@931: using std::endl; marci@931: athos@1577: int main(int argc, char *argv[]) athos@1577: { athos@1577: if(argc<2) athos@1577: { athos@1577: std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl; athos@1577: 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; athos@1577: return 0; athos@1577: } athos@1577: athos@1577: athos@1577: //input stream to read the graph from athos@1577: std::ifstream is(argv[1]); athos@1577: 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 LengthMap; marci@931: marci@931: Graph g; marci@931: Node s, t; marci@931: LengthMap length(g); marci@931: athos@1577: readDimacs(is, 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: }