An additional simplier interface for static size graphs.
Node operator()(int) for getting node by index
int index(Node node) for getting index by node
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 // Use a DIMACS max flow file as stdin.
20 // dim_to_dot < dimacs_max_flow_file > dot_output_file
21 // This program makes a dot file from a dimacs max flow file.
22 // This program can be an aid in making up to date visualized documantation
25 // For later documentation (if marci does not do it)
26 // Az a graphviz csomag egy egyszeru formatuma, ami egy graphrajzolo csomag.
27 // Az EdgeSubGraphAdaptor doksijaban szerepel egy kirajzolt graf. Azt nem
28 // kezzel csinaltam, hanem a megfelelo dim file-bol ezzel a progival. A
29 // doxygen ugyanis ilyet eszik, igy a juzer vizualisan is latja a grafot a
30 // doksiban, es sajat maga is le tudja futtatni az algoritmust, mert ott van
31 // a kezeben a dim file is. Es mivel ez egy generalt file, ezert ha vmit
32 // valtoztatunk a dim-en, ezt is konnyu bemasolni. Uff.
38 #include <lemon/smart_graph.h>
39 #include <lemon/dimacs.h>
41 using namespace lemon;
46 int main(int argc, char *argv[])
50 std::cerr << "USAGE: sub_graph_adaptor_demo input_file.dim" << std::endl;
51 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;
56 //input stream to read the graph from
57 std::ifstream is(argv[1]);
59 typedef SmartGraph Graph;
61 typedef Graph::Edge Edge;
62 typedef Graph::Node Node;
63 typedef Graph::EdgeIt EdgeIt;
64 typedef Graph::NodeIt NodeIt;
65 typedef Graph::EdgeMap<int> LengthMap;
71 readDimacs(is, g, length, s, t);
73 cout << "digraph lemon_dot_example {" << endl;
74 cout << " node [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
75 for(NodeIt n(g); n!=INVALID; ++n) {
77 cout << " n" << g.id(n)
78 << " [ label=\"" << g.id(n) << " (s)\" ]; " << endl;
81 cout << " n" << g.id(n)
82 << " [ label=\"" << g.id(n) << " (t)\" ]; " << endl;
84 cout << " n" << g.id(n)
85 << " [ label=\"" << g.id(n) << "\" ]; " << endl;
89 cout << " edge [ shape=ellipse, fontname=Helvetica, fontsize=10 ];" << endl;
90 for(EdgeIt e(g); e!=INVALID; ++e) {
91 cout << " n" << g.id(g.source(e)) << " -> " << " n" << g.id(g.target(e))
92 << " [ label=\"" << g.id(e)
93 << ", length:" << length[e] << "\" ]; " << endl;