alpar@1073: /* -*- C++ -*- alpar@1073: * src/lemon/demo/graph_to_eps.cc - alpar@1073: * Part of LEMON, a generic C++ optimization library alpar@1073: * alpar@1164: * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1073: * (Egervary Combinatorial Optimization Research Group, EGRES). alpar@1073: * alpar@1073: * Permission to use, modify and distribute this software is granted alpar@1073: * provided that this copyright notice appears in all copies. For alpar@1073: * precise terms see the accompanying LICENSE file. alpar@1073: * alpar@1073: * This software is provided "AS IS" with no warranty of any kind, alpar@1073: * express or implied, and with no claim as to its suitability for any alpar@1073: * purpose. alpar@1073: * alpar@1073: */ alpar@1073: alpar@1073: #include alpar@1073: #include alpar@1073: #include alpar@1268: #include alpar@1073: alpar@1073: alpar@1073: using namespace std; alpar@1073: using namespace lemon; alpar@1073: alpar@1073: int main() alpar@1073: { alpar@1178: ColorSet colorSet; alpar@1178: alpar@1073: ListGraph g; alpar@1073: typedef ListGraph::Node Node; alpar@1073: typedef ListGraph::NodeIt NodeIt; alpar@1073: typedef ListGraph::Edge Edge; alpar@1073: typedef xy Xy; alpar@1073: alpar@1073: Node n1=g.addNode(); alpar@1073: Node n2=g.addNode(); alpar@1073: Node n3=g.addNode(); alpar@1073: Node n4=g.addNode(); alpar@1073: Node n5=g.addNode(); alpar@1073: alpar@1073: ListGraph::NodeMap coords(g); alpar@1073: ListGraph::NodeMap sizes(g); alpar@1073: ListGraph::NodeMap colors(g); alpar@1086: ListGraph::NodeMap shapes(g); alpar@1073: ListGraph::EdgeMap ecolors(g); alpar@1073: ListGraph::EdgeMap widths(g); alpar@1073: alpar@1086: coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0; alpar@1088: coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2; alpar@1086: coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0; alpar@1086: coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1; alpar@1088: coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2; alpar@1073: alpar@1073: Edge e; alpar@1073: alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=0; widths[e]=1; alpar@1073: e=g.addEdge(n2,n3); ecolors[e]=0; widths[e]=1; alpar@1073: e=g.addEdge(n3,n5); ecolors[e]=0; widths[e]=3; alpar@1073: e=g.addEdge(n5,n4); ecolors[e]=0; widths[e]=1; alpar@1073: e=g.addEdge(n4,n1); ecolors[e]=0; widths[e]=1; alpar@1073: e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2; alpar@1073: e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1; alpar@1073: alpar@1268: IdMap id(g); alpar@1073: alpar@1073: graphToEps(g,"graph_to_eps_demo_out.eps").scale(10).coords(coords). alpar@1108: title("Sample .eps figure"). alpar@1164: copyright("(C) 2005 LEMON Project"). alpar@1073: nodeScale(2).nodeSizes(sizes). alpar@1086: nodeShapes(shapes). alpar@1073: nodeColors(composeMap(colorSet,colors)). alpar@1073: edgeColors(composeMap(colorSet,ecolors)). alpar@1073: edgeWidthScale(.4).edgeWidths(widths). alpar@1091: nodeTexts(id).nodeTextSize(3). alpar@1091: run(); alpar@1073: alpar@1091: graphToEps(g,"graph_to_eps_demo_out_arr.eps").scale(10). alpar@1108: title("Sample .eps figure (with arrowheads)"). alpar@1164: copyright("(C) 2005 LEMON Project"). alpar@1091: nodeColors(composeMap(colorSet,colors)). alpar@1091: coords(coords). alpar@1073: nodeScale(2).nodeSizes(sizes). alpar@1086: nodeShapes(shapes). alpar@1073: edgeColors(composeMap(colorSet,ecolors)). alpar@1073: edgeWidthScale(.4).edgeWidths(widths). alpar@1073: nodeTexts(id).nodeTextSize(3). alpar@1091: drawArrows().arrowWidth(1).arrowLength(1). alpar@1091: run(); alpar@1073: alpar@1073: e=g.addEdge(n1,n4); ecolors[e]=2; widths[e]=1; alpar@1073: e=g.addEdge(n4,n1); ecolors[e]=1; widths[e]=2; alpar@1073: alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=1; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=2; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=3; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=4; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=5; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=6; widths[e]=1; alpar@1073: e=g.addEdge(n1,n2); ecolors[e]=7; widths[e]=1; alpar@1073: alpar@1091: graphToEps(g,"graph_to_eps_demo_out_par.eps").scale(10). alpar@1108: title("Sample .eps figure (parallel edges)"). alpar@1164: copyright("(C) 2005 LEMON Project"). alpar@1091: nodeShapes(shapes). alpar@1091: coords(coords). alpar@1073: nodeScale(2).nodeSizes(sizes). alpar@1073: nodeColors(composeMap(colorSet,colors)). alpar@1073: edgeColors(composeMap(colorSet,ecolors)). alpar@1073: edgeWidthScale(.4).edgeWidths(widths). alpar@1073: nodeTexts(id).nodeTextSize(3). alpar@1091: enableParallel().parEdgeDist(1.5). alpar@1091: run(); alpar@1091: alpar@1091: graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").scale(10). alpar@1108: title("Sample .eps figure (parallel edges and arrowheads)"). alpar@1164: copyright("(C) 2005 LEMON Project"). alpar@1073: nodeScale(2).nodeSizes(sizes). alpar@1091: coords(coords). alpar@1086: nodeShapes(shapes). alpar@1073: nodeColors(composeMap(colorSet,colors)). alpar@1073: edgeColors(composeMap(colorSet,ecolors)). alpar@1073: edgeWidthScale(.3).edgeWidths(widths). alpar@1073: nodeTexts(id).nodeTextSize(3). alpar@1073: enableParallel().parEdgeDist(1). alpar@1091: drawArrows().arrowWidth(1).arrowLength(1). alpar@1103: run(); alpar@1103: alpar@1103: graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4(). alpar@1108: title("Sample .eps figure (fits to A4)"). alpar@1164: copyright("(C) 2005 LEMON Project"). alpar@1103: nodeScale(2).nodeSizes(sizes). alpar@1103: coords(coords). alpar@1103: nodeShapes(shapes). alpar@1103: nodeColors(composeMap(colorSet,colors)). alpar@1103: edgeColors(composeMap(colorSet,ecolors)). alpar@1103: edgeWidthScale(.3).edgeWidths(widths). alpar@1103: nodeTexts(id).nodeTextSize(3). alpar@1103: enableParallel().parEdgeDist(1). alpar@1103: drawArrows().arrowWidth(1).arrowLength(1). alpar@1103: run(); alpar@1103: alpar@1178: ListGraph h; alpar@1178: ListGraph::NodeMap hcolors(h); alpar@1178: ListGraph::NodeMap hcoords(h); alpar@1178: alpar@1178: int cols=int(sqrt(double(colorSet.size()))); alpar@1178: for(int i=0;i