demo/graph_to_eps_demo.cc
changeset 2172 4b25e7003868
parent 1956 a055123339d5
child 2178 0d7c0f96a5ee
equal deleted inserted replaced
8:7e83790f89e2 9:942b02b55efb
    39 using namespace std;
    39 using namespace std;
    40 using namespace lemon;
    40 using namespace lemon;
    41 
    41 
    42 int main()
    42 int main()
    43 {
    43 {
    44   ColorSet colorSet;
    44   Palette palette;
    45 
    45 
    46   ListGraph g;
    46   ListGraph g;
    47   typedef ListGraph::Node Node;
    47   typedef ListGraph::Node Node;
    48   typedef ListGraph::NodeIt NodeIt;
    48   typedef ListGraph::NodeIt NodeIt;
    49   typedef ListGraph::Edge Edge;
    49   typedef ListGraph::Edge Edge;
    86     coords(coords).
    86     coords(coords).
    87     title("Sample .eps figure").
    87     title("Sample .eps figure").
    88     copyright("(C) 2006 LEMON Project").
    88     copyright("(C) 2006 LEMON Project").
    89     nodeScale(2).nodeSizes(sizes).
    89     nodeScale(2).nodeSizes(sizes).
    90     nodeShapes(shapes).
    90     nodeShapes(shapes).
    91     nodeColors(composeMap(colorSet,colors)).
    91     nodeColors(composeMap(palette,colors)).
    92     edgeColors(composeMap(colorSet,ecolors)).
    92     edgeColors(composeMap(palette,ecolors)).
    93     edgeWidthScale(.4).edgeWidths(widths).
    93     edgeWidthScale(.4).edgeWidths(widths).
    94     nodeTexts(id).nodeTextSize(3).
    94     nodeTexts(id).nodeTextSize(3).
    95     run();
    95     run();
    96 
    96 
    97 
    97 
    98   cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
    98   cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
    99   graphToEps(g,"graph_to_eps_demo_out_arr.eps").
    99   graphToEps(g,"graph_to_eps_demo_out_arr.eps").
   100     //scale(10).
   100     //scale(10).
   101     title("Sample .eps figure (with arrowheads)").
   101     title("Sample .eps figure (with arrowheads)").
   102     copyright("(C) 2006 LEMON Project").
   102     copyright("(C) 2006 LEMON Project").
   103     nodeColors(composeMap(colorSet,colors)).
   103     nodeColors(composeMap(palette,colors)).
   104     coords(coords).
   104     coords(coords).
   105     nodeScale(2).nodeSizes(sizes).
   105     nodeScale(2).nodeSizes(sizes).
   106     nodeShapes(shapes).
   106     nodeShapes(shapes).
   107     edgeColors(composeMap(colorSet,ecolors)).
   107     edgeColors(composeMap(palette,ecolors)).
   108     edgeWidthScale(.4).edgeWidths(widths).
   108     edgeWidthScale(.4).edgeWidths(widths).
   109     nodeTexts(id).nodeTextSize(3).
   109     nodeTexts(id).nodeTextSize(3).
   110     drawArrows().arrowWidth(1).arrowLength(1).
   110     drawArrows().arrowWidth(1).arrowLength(1).
   111     run();
   111     run();
   112 
   112 
   127     title("Sample .eps figure (parallel edges)").
   127     title("Sample .eps figure (parallel edges)").
   128     copyright("(C) 2006 LEMON Project").
   128     copyright("(C) 2006 LEMON Project").
   129     nodeShapes(shapes).
   129     nodeShapes(shapes).
   130     coords(coords).
   130     coords(coords).
   131     nodeScale(2).nodeSizes(sizes).
   131     nodeScale(2).nodeSizes(sizes).
   132     nodeColors(composeMap(colorSet,colors)).
   132     nodeColors(composeMap(palette,colors)).
   133     edgeColors(composeMap(colorSet,ecolors)).
   133     edgeColors(composeMap(palette,ecolors)).
   134     edgeWidthScale(.4).edgeWidths(widths).
   134     edgeWidthScale(.4).edgeWidths(widths).
   135     nodeTexts(id).nodeTextSize(3).
   135     nodeTexts(id).nodeTextSize(3).
   136     enableParallel().parEdgeDist(1.5).
   136     enableParallel().parEdgeDist(1.5).
   137     run();
   137     run();
   138   
   138   
   142     title("Sample .eps figure (parallel edges and arrowheads)").
   142     title("Sample .eps figure (parallel edges and arrowheads)").
   143     copyright("(C) 2006 LEMON Project").
   143     copyright("(C) 2006 LEMON Project").
   144     nodeScale(2).nodeSizes(sizes).
   144     nodeScale(2).nodeSizes(sizes).
   145     coords(coords).
   145     coords(coords).
   146     nodeShapes(shapes).
   146     nodeShapes(shapes).
   147     nodeColors(composeMap(colorSet,colors)).
   147     nodeColors(composeMap(palette,colors)).
   148     edgeColors(composeMap(colorSet,ecolors)).
   148     edgeColors(composeMap(palette,ecolors)).
   149     edgeWidthScale(.3).edgeWidths(widths).
   149     edgeWidthScale(.3).edgeWidths(widths).
   150     nodeTexts(id).nodeTextSize(3).
   150     nodeTexts(id).nodeTextSize(3).
   151     enableParallel().parEdgeDist(1).
   151     enableParallel().parEdgeDist(1).
   152     drawArrows().arrowWidth(1).arrowLength(1).
   152     drawArrows().arrowWidth(1).arrowLength(1).
   153     run();
   153     run();
   157     title("Sample .eps figure (fits to A4)").
   157     title("Sample .eps figure (fits to A4)").
   158     copyright("(C) 2006 LEMON Project").
   158     copyright("(C) 2006 LEMON Project").
   159     nodeScale(2).nodeSizes(sizes).
   159     nodeScale(2).nodeSizes(sizes).
   160     coords(coords).
   160     coords(coords).
   161     nodeShapes(shapes).
   161     nodeShapes(shapes).
   162     nodeColors(composeMap(colorSet,colors)).
   162     nodeColors(composeMap(palette,colors)).
   163     edgeColors(composeMap(colorSet,ecolors)).
   163     edgeColors(composeMap(palette,ecolors)).
   164     edgeWidthScale(.3).edgeWidths(widths).
   164     edgeWidthScale(.3).edgeWidths(widths).
   165     nodeTexts(id).nodeTextSize(3).
   165     nodeTexts(id).nodeTextSize(3).
   166     enableParallel().parEdgeDist(1).
   166     enableParallel().parEdgeDist(1).
   167     drawArrows().arrowWidth(1).arrowLength(1).
   167     drawArrows().arrowWidth(1).arrowLength(1).
   168     run();
   168     run();
   169 
   169 
   170   ListGraph h;
   170   ListGraph h;
   171   ListGraph::NodeMap<int> hcolors(h);
   171   ListGraph::NodeMap<int> hcolors(h);
   172   ListGraph::NodeMap<Xy> hcoords(h);
   172   ListGraph::NodeMap<Xy> hcoords(h);
   173   
   173   
   174   int cols=int(sqrt(double(colorSet.size())));
   174   int cols=int(sqrt(double(palette.size())));
   175   for(int i=0;i<int(colorSet.size());i++) {
   175   for(int i=0;i<int(palette.size());i++) {
   176     Node n=h.addNode();
   176     Node n=h.addNode();
   177     hcoords[n]=Xy(i%cols,i/cols);
   177     hcoords[n]=Xy(i%cols,i/cols);
   178     hcolors[n]=i;
   178     hcolors[n]=i;
   179   }
   179   }
   180   
   180   
   181   cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
   181   cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
   182   graphToEps(h,"graph_to_eps_demo_out_colors.eps").
   182   graphToEps(h,"graph_to_eps_demo_out_colors.eps").
   183     //scale(60).
   183     //scale(60).
   184     title("Sample .eps figure (ColorSet demo)").
   184     title("Sample .eps figure (Palette demo)").
   185     copyright("(C) 2006 LEMON Project").
   185     copyright("(C) 2006 LEMON Project").
   186     coords(hcoords).
   186     coords(hcoords).
   187     nodeScale(.45).
   187     nodeScale(.45).
   188     distantColorNodeTexts().
   188     distantColorNodeTexts().
   189     //    distantBWNodeTexts().
   189     //    distantBWNodeTexts().
   190     nodeTexts(hcolors).nodeTextSize(.6).
   190     nodeTexts(hcolors).nodeTextSize(.6).
   191     nodeColors(composeMap(colorSet,hcolors)).
   191     nodeColors(composeMap(palette,hcolors)).
   192     run();
   192     run();
   193 
   193 
   194 
   194 
   195 }
   195 }