demo/graph_to_eps_demo.cc
changeset 2203 5f1a83b565fb
parent 2172 4b25e7003868
child 2207 75a29ac69c19
equal deleted inserted replaced
9:942b02b55efb 10:21f9af742bc9
    40 using namespace lemon;
    40 using namespace lemon;
    41 
    41 
    42 int main()
    42 int main()
    43 {
    43 {
    44   Palette palette;
    44   Palette palette;
       
    45   Palette paletteW(true);
    45 
    46 
    46   ListGraph g;
    47   ListGraph g;
    47   typedef ListGraph::Node Node;
    48   typedef ListGraph::Node Node;
    48   typedef ListGraph::NodeIt NodeIt;
    49   typedef ListGraph::NodeIt NodeIt;
    49   typedef ListGraph::Edge Edge;
    50   typedef ListGraph::Edge Edge;
    78   e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
    79   e=g.addEdge(n2,n4); ecolors[e]=1; widths[e]=2;
    79   e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
    80   e=g.addEdge(n3,n4); ecolors[e]=2; widths[e]=1;
    80   
    81   
    81   IdMap<ListGraph,Node> id(g);
    82   IdMap<ListGraph,Node> id(g);
    82 
    83 
       
    84   cout << "Create 'graph_to_eps_demo_out_pure.eps'" << endl;
       
    85   graphToEps(g,"graph_to_eps_demo_out_pure.eps").
       
    86     //scale(10).
       
    87     coords(coords).
       
    88     title("Sample .eps figure").
       
    89     copyright("(C) 2006 LEMON Project").
       
    90     run();
       
    91 
    83   cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
    92   cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
    84   graphToEps(g,"graph_to_eps_demo_out.eps").
    93   graphToEps(g,"graph_to_eps_demo_out.eps").
    85     //scale(10).
    94     //scale(10).
    86     coords(coords).
    95     coords(coords).
    87     title("Sample .eps figure").
    96     title("Sample .eps figure").
    88     copyright("(C) 2006 LEMON Project").
    97     copyright("(C) 2006 LEMON Project").
       
    98     absoluteNodeSizes().absoluteEdgeWidths().
    89     nodeScale(2).nodeSizes(sizes).
    99     nodeScale(2).nodeSizes(sizes).
    90     nodeShapes(shapes).
   100     nodeShapes(shapes).
    91     nodeColors(composeMap(palette,colors)).
   101     nodeColors(composeMap(palette,colors)).
    92     edgeColors(composeMap(palette,ecolors)).
   102     edgeColors(composeMap(palette,ecolors)).
    93     edgeWidthScale(.4).edgeWidths(widths).
   103     edgeWidthScale(.4).edgeWidths(widths).
    98   cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
   108   cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
    99   graphToEps(g,"graph_to_eps_demo_out_arr.eps").
   109   graphToEps(g,"graph_to_eps_demo_out_arr.eps").
   100     //scale(10).
   110     //scale(10).
   101     title("Sample .eps figure (with arrowheads)").
   111     title("Sample .eps figure (with arrowheads)").
   102     copyright("(C) 2006 LEMON Project").
   112     copyright("(C) 2006 LEMON Project").
       
   113     absoluteNodeSizes().absoluteEdgeWidths().
   103     nodeColors(composeMap(palette,colors)).
   114     nodeColors(composeMap(palette,colors)).
   104     coords(coords).
   115     coords(coords).
   105     nodeScale(2).nodeSizes(sizes).
   116     nodeScale(2).nodeSizes(sizes).
   106     nodeShapes(shapes).
   117     nodeShapes(shapes).
   107     edgeColors(composeMap(palette,ecolors)).
   118     edgeColors(composeMap(palette,ecolors)).
   124   cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
   135   cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
   125   graphToEps(g,"graph_to_eps_demo_out_par.eps").
   136   graphToEps(g,"graph_to_eps_demo_out_par.eps").
   126     //scale(10).
   137     //scale(10).
   127     title("Sample .eps figure (parallel edges)").
   138     title("Sample .eps figure (parallel edges)").
   128     copyright("(C) 2006 LEMON Project").
   139     copyright("(C) 2006 LEMON Project").
       
   140     absoluteNodeSizes().absoluteEdgeWidths().
   129     nodeShapes(shapes).
   141     nodeShapes(shapes).
   130     coords(coords).
   142     coords(coords).
   131     nodeScale(2).nodeSizes(sizes).
   143     nodeScale(2).nodeSizes(sizes).
   132     nodeColors(composeMap(palette,colors)).
   144     nodeColors(composeMap(palette,colors)).
   133     edgeColors(composeMap(palette,ecolors)).
   145     edgeColors(composeMap(palette,ecolors)).
   139   cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
   151   cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
   140   graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
   152   graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
   141     //scale(10).
   153     //scale(10).
   142     title("Sample .eps figure (parallel edges and arrowheads)").
   154     title("Sample .eps figure (parallel edges and arrowheads)").
   143     copyright("(C) 2006 LEMON Project").
   155     copyright("(C) 2006 LEMON Project").
       
   156     absoluteNodeSizes().absoluteEdgeWidths().
   144     nodeScale(2).nodeSizes(sizes).
   157     nodeScale(2).nodeSizes(sizes).
   145     coords(coords).
   158     coords(coords).
   146     nodeShapes(shapes).
   159     nodeShapes(shapes).
   147     nodeColors(composeMap(palette,colors)).
   160     nodeColors(composeMap(palette,colors)).
   148     edgeColors(composeMap(palette,ecolors)).
   161     edgeColors(composeMap(palette,ecolors)).
   154 
   167 
   155   cout << "Create 'graph_to_eps_demo_out_a4.eps'" << endl;
   168   cout << "Create 'graph_to_eps_demo_out_a4.eps'" << endl;
   156   graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
   169   graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
   157     title("Sample .eps figure (fits to A4)").
   170     title("Sample .eps figure (fits to A4)").
   158     copyright("(C) 2006 LEMON Project").
   171     copyright("(C) 2006 LEMON Project").
       
   172     absoluteNodeSizes().absoluteEdgeWidths().
   159     nodeScale(2).nodeSizes(sizes).
   173     nodeScale(2).nodeSizes(sizes).
   160     coords(coords).
   174     coords(coords).
   161     nodeShapes(shapes).
   175     nodeShapes(shapes).
   162     nodeColors(composeMap(palette,colors)).
   176     nodeColors(composeMap(palette,colors)).
   163     edgeColors(composeMap(palette,ecolors)).
   177     edgeColors(composeMap(palette,ecolors)).
   170   ListGraph h;
   184   ListGraph h;
   171   ListGraph::NodeMap<int> hcolors(h);
   185   ListGraph::NodeMap<int> hcolors(h);
   172   ListGraph::NodeMap<Xy> hcoords(h);
   186   ListGraph::NodeMap<Xy> hcoords(h);
   173   
   187   
   174   int cols=int(sqrt(double(palette.size())));
   188   int cols=int(sqrt(double(palette.size())));
   175   for(int i=0;i<int(palette.size());i++) {
   189   for(int i=0;i<int(paletteW.size());i++) {
   176     Node n=h.addNode();
   190     Node n=h.addNode();
   177     hcoords[n]=Xy(i%cols,i/cols);
   191     hcoords[n]=Xy(i%cols,i/cols);
   178     hcolors[n]=i;
   192     hcolors[n]=i;
   179   }
   193   }
   180   
   194   
   182   graphToEps(h,"graph_to_eps_demo_out_colors.eps").
   196   graphToEps(h,"graph_to_eps_demo_out_colors.eps").
   183     //scale(60).
   197     //scale(60).
   184     title("Sample .eps figure (Palette demo)").
   198     title("Sample .eps figure (Palette demo)").
   185     copyright("(C) 2006 LEMON Project").
   199     copyright("(C) 2006 LEMON Project").
   186     coords(hcoords).
   200     coords(hcoords).
   187     nodeScale(.45).
   201     absoluteNodeSizes().absoluteEdgeWidths().
       
   202     nodeScale(45).
   188     distantColorNodeTexts().
   203     distantColorNodeTexts().
   189     //    distantBWNodeTexts().
   204     //    distantBWNodeTexts().
   190     nodeTexts(hcolors).nodeTextSize(.6).
   205     nodeTexts(hcolors).nodeTextSize(.6).
   191     nodeColors(composeMap(palette,hcolors)).
   206     nodeColors(composeMap(paletteW,hcolors)).
   192     run();
   207     run();
   193 
       
   194 
       
   195 }
   208 }