1.1 --- a/src/demo/graph_to_eps_demo.cc Sat May 21 21:04:57 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,169 +0,0 @@
1.4 -/* -*- C++ -*-
1.5 - * src/lemon/demo/graph_to_eps.cc -
1.6 - * Part of LEMON, a generic C++ optimization library
1.7 - *
1.8 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.9 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.10 - *
1.11 - * Permission to use, modify and distribute this software is granted
1.12 - * provided that this copyright notice appears in all copies. For
1.13 - * precise terms see the accompanying LICENSE file.
1.14 - *
1.15 - * This software is provided "AS IS" with no warranty of any kind,
1.16 - * express or implied, and with no claim as to its suitability for any
1.17 - * purpose.
1.18 - *
1.19 - */
1.20 -
1.21 -#include<lemon/graph_to_eps.h>
1.22 -#include<lemon/maps.h>
1.23 -#include<lemon/list_graph.h>
1.24 -#include<lemon/graph_utils.h>
1.25 -
1.26 -#include <cmath>
1.27 -
1.28 -
1.29 -using namespace std;
1.30 -using namespace lemon;
1.31 -
1.32 -int main()
1.33 -{
1.34 - ColorSet colorSet;
1.35 -
1.36 - ListGraph g;
1.37 - typedef ListGraph::Node Node;
1.38 - typedef ListGraph::NodeIt NodeIt;
1.39 - typedef ListGraph::Edge Edge;
1.40 - typedef xy<int> Xy;
1.41 -
1.42 - Node n1=g.addNode();
1.43 - Node n2=g.addNode();
1.44 - Node n3=g.addNode();
1.45 - Node n4=g.addNode();
1.46 - Node n5=g.addNode();
1.47 -
1.48 - ListGraph::NodeMap<Xy> coords(g);
1.49 - ListGraph::NodeMap<double> sizes(g);
1.50 - ListGraph::NodeMap<int> colors(g);
1.51 - ListGraph::NodeMap<int> shapes(g);
1.52 - ListGraph::EdgeMap<int> ecolors(g);
1.53 - ListGraph::EdgeMap<int> widths(g);
1.54 -
1.55 - coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
1.56 - coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
1.57 - coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
1.58 - coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
1.59 - coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
1.60 -
1.61 - Edge e;
1.62 -
1.63 - e=g.addEdge(n1,n2); ecolors[e]=0; widths[e]=1;
1.64 - e=g.addEdge(n2,n3); ecolors[e]=0; widths[e]=1;
1.65 - e=g.addEdge(n3,n5); ecolors[e]=0; widths[e]=3;
1.66 - e=g.addEdge(n5,n4); ecolors[e]=0; widths[e]=1;
1.67 - e=g.addEdge(n4,n1); ecolors[e]=0; widths[e]=1;
1.68 - e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
1.69 - e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
1.70 -
1.71 - IdMap<ListGraph,Node> id(g);
1.72 -
1.73 - graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords).
1.74 - title("Sample .eps figure").
1.75 - copyright("(C) 2005 LEMON Project").
1.76 - nodeScale(2).nodeSizes(sizes).
1.77 - nodeShapes(shapes).
1.78 - nodeColors(composeMap(colorSet,colors)).
1.79 - edgeColors(composeMap(colorSet,ecolors)).
1.80 - edgeWidthScale(.4).edgeWidths(widths).
1.81 - nodeTexts(id).nodeTextSize(3).
1.82 - run();
1.83 -
1.84 - graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10).
1.85 - title("Sample .eps figure (with arrowheads)").
1.86 - copyright("(C) 2005 LEMON Project").
1.87 - nodeColors(composeMap(colorSet,colors)).
1.88 - coords(coords).
1.89 - nodeScale(2).nodeSizes(sizes).
1.90 - nodeShapes(shapes).
1.91 - edgeColors(composeMap(colorSet,ecolors)).
1.92 - edgeWidthScale(.4).edgeWidths(widths).
1.93 - nodeTexts(id).nodeTextSize(3).
1.94 - drawArrows().arrowWidth(1).arrowLength(1).
1.95 - run();
1.96 -
1.97 - e=g.addEdge(n1,n4); ecolors[e]=2; widths[e]=1;
1.98 - e=g.addEdge(n4,n1); ecolors[e]=1; widths[e]=2;
1.99 -
1.100 - e=g.addEdge(n1,n2); ecolors[e]=1; widths[e]=1;
1.101 - e=g.addEdge(n1,n2); ecolors[e]=2; widths[e]=1;
1.102 - e=g.addEdge(n1,n2); ecolors[e]=3; widths[e]=1;
1.103 - e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1;
1.104 - e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1;
1.105 - e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1;
1.106 - e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1;
1.107 -
1.108 - graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10).
1.109 - title("Sample .eps figure (parallel edges)").
1.110 - copyright("(C) 2005 LEMON Project").
1.111 - nodeShapes(shapes).
1.112 - coords(coords).
1.113 - nodeScale(2).nodeSizes(sizes).
1.114 - nodeColors(composeMap(colorSet,colors)).
1.115 - edgeColors(composeMap(colorSet,ecolors)).
1.116 - edgeWidthScale(.4).edgeWidths(widths).
1.117 - nodeTexts(id).nodeTextSize(3).
1.118 - enableParallel().parEdgeDist(1.5).
1.119 - run();
1.120 -
1.121 - graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10).
1.122 - title("Sample .eps figure (parallel edges and arrowheads)").
1.123 - copyright("(C) 2005 LEMON Project").
1.124 - nodeScale(2).nodeSizes(sizes).
1.125 - coords(coords).
1.126 - nodeShapes(shapes).
1.127 - nodeColors(composeMap(colorSet,colors)).
1.128 - edgeColors(composeMap(colorSet,ecolors)).
1.129 - edgeWidthScale(.3).edgeWidths(widths).
1.130 - nodeTexts(id).nodeTextSize(3).
1.131 - enableParallel().parEdgeDist(1).
1.132 - drawArrows().arrowWidth(1).arrowLength(1).
1.133 - run();
1.134 -
1.135 - graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
1.136 - title("Sample .eps figure (fits to A4)").
1.137 - copyright("(C) 2005 LEMON Project").
1.138 - nodeScale(2).nodeSizes(sizes).
1.139 - coords(coords).
1.140 - nodeShapes(shapes).
1.141 - nodeColors(composeMap(colorSet,colors)).
1.142 - edgeColors(composeMap(colorSet,ecolors)).
1.143 - edgeWidthScale(.3).edgeWidths(widths).
1.144 - nodeTexts(id).nodeTextSize(3).
1.145 - enableParallel().parEdgeDist(1).
1.146 - drawArrows().arrowWidth(1).arrowLength(1).
1.147 - run();
1.148 -
1.149 - ListGraph h;
1.150 - ListGraph::NodeMap<int> hcolors(h);
1.151 - ListGraph::NodeMap<Xy> hcoords(h);
1.152 -
1.153 - int cols=int(sqrt(double(colorSet.size())));
1.154 - for(int i=0;i<int(colorSet.size());i++) {
1.155 - Node n=h.addNode();
1.156 - hcoords[n]=Xy(i%cols,i/cols);
1.157 - hcolors[n]=i;
1.158 - }
1.159 -
1.160 - graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
1.161 - title("Sample .eps figure (parallel edges and arrowheads)").
1.162 - copyright("(C) 2005 LEMON Project").
1.163 - coords(hcoords).
1.164 - nodeScale(.45).
1.165 - distantColorNodeTexts().
1.166 - // distantBWNodeTexts().
1.167 - nodeTexts(hcolors).nodeTextSize(.6).
1.168 - nodeColors(composeMap(colorSet,hcolors)).
1.169 - run();
1.170 -
1.171 -
1.172 -}