More "doxygenish" syntax.
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 #include <lemon/list_graph.h>
20 #include <lemon/graph_reader.h>
21 #include <lemon/iterable_maps.h>
23 #include <lemon/graph_to_eps.h>
26 using namespace lemon;
29 typedef ListGraph::Node Node;
30 typedef ListGraph::NodeIt NodeIt;
31 typedef ListGraph::Edge Edge;
32 typedef ListGraph::EdgeIt EdgeIt;
33 typedef ListGraph::OutEdgeIt OutEdgeIt;
34 typedef ListGraph::InEdgeIt InEdgeIt;
36 int main(int argc, char** argv)
39 std::cerr << "\n USAGE: " << argv[0]
40 << " input_file.lgf" << std::endl << std::endl;
41 std::cerr << " The file 'input_file.lgf' has to contain "
42 << "at least three node maps called \n 'f', 'coordinates_x' "
43 << "and 'coordinates_y'.\n"
44 << " The in-degree requirement is given by 'f', while the two "
45 << "others is used\n to create to output drawing."
52 ListGraph::NodeMap<int> f(g); //in-deg requirement;
53 ListGraph::NodeMap<int> label(g);
54 ListGraph::NodeMap<xy<double> > coords(g);
57 GraphReader<ListGraph> reader(argv[1],g);
58 reader.readNodeMap("f",f);
59 reader.readNodeMap("label",label);
60 reader.readNodeMap("coordinates_x",xMap(coords));
61 reader.readNodeMap("coordinates_y",yMap(coords));
63 } catch (DataFormatError& error) {
64 std::cerr << error.what() << std::endl;
69 ListGraph::NodeMap<int> level(g,0);
71 ListGraph::NodeMap<int> def(g); //deficiency of the nodes
72 def = subMap(f,InDegMap<ListGraph>(g));
74 IterableBoolMap<ListGraph, Node> active(g,false);
75 for(NodeIt n(g);n!=INVALID;++n) active[n]=(def[n]>0);
77 ListGraph::EdgeMap<bool> rev(g,false); // rev[e]==true <=> e is to be
80 int nodeNum=countNodes(g);
83 while((act=IterableBoolMap<ListGraph, Node>::TrueIt(active))!=INVALID) {
84 std::cout << "Process node " << label[act]
85 << " (def=" << def[act]
86 << " lev=" << level[act] << "): ";
88 while(e!=INVALID && level[g.target(e)]>=level[act]) ++e;
90 std::cout << " REVERT EDGE " << g.id(e)
91 << " (" << label[g.source(e)] << "---"
92 << label[g.target(e)] << ")"
94 if(--def[act]==0) active[act]=false;
95 if(++def[g.target(e)]>0) active[g.target(e)]=true;
100 std::cout << " LIFT" << std::endl;
101 if(++level[act]>nodeNum) {
102 std::cout << "NINCS ILYEN\n";
110 graphToEps(g,"graph_orientation.eps").scaleToA4().
111 title("Sample .eps figure (fits to A4)").
112 copyright("(C) 2006 LEMON Project").
116 edgeColors(composeMap(ColorSet(),rev)).
118 nodeTexts(f).nodeTextSize(20).
119 drawArrows().arrowWidth(10).arrowLength(10).