COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
02/25/05 15:50:22 (20 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1584
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/demo/graph_to_eps_demo.cc

    r1164 r1178  
    2424using namespace lemon;
    2525
    26 class ColorSet : public MapBase<int,Color>
    27 {
    28 public:
    29   Color operator[](int i) const
    30   {
    31     switch(i%8){
    32     case 0: return Color(0,0,0);
    33     case 1: return Color(1,0,0);
    34     case 2: return Color(0,1,0);
    35     case 3: return Color(0,0,1);
    36     case 4: return Color(1,1,0);
    37     case 5: return Color(1,0,1);
    38     case 6: return Color(0,1,1);
    39     case 7: return Color(1,1,1);
    40     }
    41     return Color(0,0,0);
    42   }
    43 } colorSet;
    44 
    4526class IdMap :public MapBase<ListGraph::Node,int>
    4627{
     
    5334int main()
    5435{
     36  ColorSet colorSet;
     37
    5538  ListGraph g;
    5639  typedef ListGraph::Node Node;
     
    166149    run();
    167150
     151  ListGraph h;
     152  ListGraph::NodeMap<int> hcolors(h);
     153  ListGraph::NodeMap<Xy> hcoords(h);
     154 
     155  int cols=int(sqrt(double(colorSet.size())));
     156  for(int i=0;i<int(colorSet.size());i++) {
     157    Node n=h.addNode();
     158    hcoords[n]=Xy(i%cols,i/cols);
     159    hcolors[n]=i;
     160  }
     161 
     162  graphToEps(h,"graph_to_eps_demo_out_colors.eps").scale(60).
     163    title("Sample .eps figure (parallel edges and arrowheads)").
     164    copyright("(C) 2005 LEMON Project").
     165    coords(hcoords).
     166    nodeScale(.45).
     167    distantColorNodeTexts().
     168    //    distantBWNodeTexts().
     169    nodeTexts(hcolors).nodeTextSize(.6).
     170    nodeColors(composeMap(colorSet,hcolors)).
     171    run();
     172
     173
    168174}
Note: See TracChangeset for help on using the changeset viewer.