/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2006 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ // Use a DIMACS max flow file as stdin. // dim_to_dot < dimacs_max_flow_file > dot_output_file // This program makes a dot file from a dimacs max flow file. // This program can be an aid in making up to date visualized documantation // of demo programs. // For later documentation (if marci does not do it) // Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag. // Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem // kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A // doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a // doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van // a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit // valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff. #include #include #include #include using namespace lemon; using std::cout; using std::endl; int main(int argc, char *argv[]) { if(argc<2) { std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl; 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; return 0; } //input stream to read the graph from std::ifstream is(argv[1]); typedef SmartGraph Graph; typedef Graph::Edge Edge; typedef Graph::Node Node; typedef Graph::EdgeIt EdgeIt; typedef Graph::NodeIt NodeIt; typedef Graph::EdgeMap LengthMap; Graph g; Node s, t; LengthMap length(g); readDimacs(is, g, length, s, t); cout << "digraph lemon_dot_example {" << endl; cout << " node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl; for(NodeIt n(g); n!=INVALID; ++n) { if (n==s) { cout << " n" << g.id(n) << " [ label=\"" << g.id(n) << " (s)\" ]; " << endl; } else { if (n==t) { cout << " n" << g.id(n) << " [ label=\"" << g.id(n) << " (t)\" ]; " << endl; } else { cout << " n" << g.id(n) << " [ label=\"" << g.id(n) << "\" ]; " << endl; } } } cout << " edge [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl; for(EdgeIt e(g); e!=INVALID; ++e) { cout << " n" << g.id(g.source(e)) << " -> " << " n" << g.id(g.target(e)) << " [ label=\"" << g.id(e) << ", length:" << length[e] << "\" ]; " << endl; } cout << "}" << endl; }