demo/graph_to_eps_demo.cc
changeset 223 cfadfeef706f
parent 209 765619b7cbb2
child 220 a5d8c039f218
equal deleted inserted replaced
4:1f7a72dfa261 5:5821fbc3922e
    18 
    18 
    19 /// \ingroup demos
    19 /// \ingroup demos
    20 /// \file
    20 /// \file
    21 /// \brief Demo of the graph drawing function \ref graphToEps()
    21 /// \brief Demo of the graph drawing function \ref graphToEps()
    22 ///
    22 ///
    23 /// This demo program shows examples how to  use the function \ref
    23 /// This demo program shows examples how to use the function \ref
    24 /// graphToEps(). It takes no input but simply creates  six
    24 /// graphToEps(). It takes no input but simply creates seven
    25 /// <tt>.eps</tt> files demonstrating the capability of \ref
    25 /// <tt>.eps</tt> files demonstrating the capability of \ref
    26 /// graphToEps(), and showing how to draw directed graphs,
    26 /// graphToEps(), and showing how to draw directed graphs,
    27 /// how to handle parallel egdes, how to change the properties (like
    27 /// how to handle parallel egdes, how to change the properties (like
    28 /// color, shape, size, title etc.) of nodes and arcs individually
    28 /// color, shape, size, title etc.) of nodes and arcs individually
    29 /// using appropriate \ref maps-page "graph maps".
    29 /// using appropriate \ref maps-page "graph maps".
    79   a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2;
    79   a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2;
    80   a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1;
    80   a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1;
    81 
    81 
    82   IdMap<ListDigraph,Node> id(g);
    82   IdMap<ListDigraph,Node> id(g);
    83 
    83 
    84   // Create five .eps files showing the digraph with different options
    84   // Create .eps files showing the digraph with different options
    85   cout << "Create 'graph_to_eps_demo_out_1_pure.eps'" << endl;
    85   cout << "Create 'graph_to_eps_demo_out_1_pure.eps'" << endl;
    86   graphToEps(g,"graph_to_eps_demo_out_1_pure.eps").
    86   graphToEps(g,"graph_to_eps_demo_out_1_pure.eps").
    87     coords(coords).
    87     coords(coords).
    88     title("Sample .eps figure").
    88     title("Sample .eps figure").
    89     copyright("(C) 2003-2008 LEMON Project").
    89     copyright("(C) 2003-2008 LEMON Project").
   116     arcWidthScale(.4).arcWidths(widths).
   116     arcWidthScale(.4).arcWidths(widths).
   117     nodeTexts(id).nodeTextSize(3).
   117     nodeTexts(id).nodeTextSize(3).
   118     drawArrows().arrowWidth(2).arrowLength(2).
   118     drawArrows().arrowWidth(2).arrowLength(2).
   119     run();
   119     run();
   120 
   120 
       
   121   // Add more arcs to the digraph
   121   a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1;
   122   a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1;
   122   a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2;
   123   a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2;
   123 
   124 
   124   a=g.addArc(n1,n2); acolors[a]=1; widths[a]=1;
   125   a=g.addArc(n1,n2); acolors[a]=1; widths[a]=1;
   125   a=g.addArc(n1,n2); acolors[a]=2; widths[a]=1;
   126   a=g.addArc(n1,n2); acolors[a]=2; widths[a]=1;
   127   a=g.addArc(n1,n2); acolors[a]=4; widths[a]=1;
   128   a=g.addArc(n1,n2); acolors[a]=4; widths[a]=1;
   128   a=g.addArc(n1,n2); acolors[a]=5; widths[a]=1;
   129   a=g.addArc(n1,n2); acolors[a]=5; widths[a]=1;
   129   a=g.addArc(n1,n2); acolors[a]=6; widths[a]=1;
   130   a=g.addArc(n1,n2); acolors[a]=6; widths[a]=1;
   130   a=g.addArc(n1,n2); acolors[a]=7; widths[a]=1;
   131   a=g.addArc(n1,n2); acolors[a]=7; widths[a]=1;
   131 
   132 
   132   cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
   133   cout << "Create 'graph_to_eps_demo_out_4_par.eps'" << endl;
   133   graphToEps(g,"graph_to_eps_demo_out_par.eps").
   134   graphToEps(g,"graph_to_eps_demo_out_4_par.eps").
   134     //scale(10).
       
   135     title("Sample .eps figure (parallel arcs)").
   135     title("Sample .eps figure (parallel arcs)").
   136     copyright("(C) 2003-2008 LEMON Project").
   136     copyright("(C) 2003-2008 LEMON Project").
   137     absoluteNodeSizes().absoluteArcWidths().
   137     absoluteNodeSizes().absoluteArcWidths().
   138     nodeShapes(shapes).
   138     nodeShapes(shapes).
   139     coords(coords).
   139     coords(coords).
   143     arcWidthScale(.4).arcWidths(widths).
   143     arcWidthScale(.4).arcWidths(widths).
   144     nodeTexts(id).nodeTextSize(3).
   144     nodeTexts(id).nodeTextSize(3).
   145     enableParallel().parArcDist(1.5).
   145     enableParallel().parArcDist(1.5).
   146     run();
   146     run();
   147 
   147 
   148   cout << "Create 'graph_to_eps_demo_out_4_par_arr.eps'" << endl;
   148   cout << "Create 'graph_to_eps_demo_out_5_par_arr.eps'" << endl;
   149   graphToEps(g,"graph_to_eps_demo_out_4_par_arr.eps").
   149   graphToEps(g,"graph_to_eps_demo_out_5_par_arr.eps").
   150     title("Sample .eps figure (parallel arcs and arrowheads)").
   150     title("Sample .eps figure (parallel arcs and arrowheads)").
   151     copyright("(C) 2003-2008 LEMON Project").
   151     copyright("(C) 2003-2008 LEMON Project").
   152     absoluteNodeSizes().absoluteArcWidths().
   152     absoluteNodeSizes().absoluteArcWidths().
   153     nodeScale(2).nodeSizes(sizes).
   153     nodeScale(2).nodeSizes(sizes).
   154     coords(coords).
   154     coords(coords).
   159     nodeTexts(id).nodeTextSize(3).
   159     nodeTexts(id).nodeTextSize(3).
   160     enableParallel().parArcDist(1).
   160     enableParallel().parArcDist(1).
   161     drawArrows().arrowWidth(1).arrowLength(1).
   161     drawArrows().arrowWidth(1).arrowLength(1).
   162     run();
   162     run();
   163 
   163 
   164   cout << "Create 'graph_to_eps_demo_out_5_par_arr_a4.eps'" << endl;
   164   cout << "Create 'graph_to_eps_demo_out_6_par_arr_a4.eps'" << endl;
   165   graphToEps(g,"graph_to_eps_demo_out_5_par_arr_a4.eps").
   165   graphToEps(g,"graph_to_eps_demo_out_6_par_arr_a4.eps").
   166     title("Sample .eps figure (fits to A4)").
   166     title("Sample .eps figure (fits to A4)").
   167     copyright("(C) 2003-2008 LEMON Project").
   167     copyright("(C) 2003-2008 LEMON Project").
   168     scaleToA4().
   168     scaleToA4().
   169     absoluteNodeSizes().absoluteArcWidths().
   169     absoluteNodeSizes().absoluteArcWidths().
   170     nodeScale(2).nodeSizes(sizes).
   170     nodeScale(2).nodeSizes(sizes).
   188     Node n=h.addNode();
   188     Node n=h.addNode();
   189     hcoords[n]=Point(1+i%cols,1+i/cols);
   189     hcoords[n]=Point(1+i%cols,1+i/cols);
   190     hcolors[n]=i;
   190     hcolors[n]=i;
   191   }
   191   }
   192 
   192 
   193   cout << "Create 'graph_to_eps_demo_out_6_colors.eps'" << endl;
   193   cout << "Create 'graph_to_eps_demo_out_7_colors.eps'" << endl;
   194   graphToEps(h,"graph_to_eps_demo_out_6_colors.eps").
   194   graphToEps(h,"graph_to_eps_demo_out_7_colors.eps").
   195     scale(60).
   195     scale(60).
   196     title("Sample .eps figure (Palette demo)").
   196     title("Sample .eps figure (Palette demo)").
   197     copyright("(C) 2003-2008 LEMON Project").
   197     copyright("(C) 2003-2008 LEMON Project").
   198     coords(hcoords).
   198     coords(hcoords).
   199     absoluteNodeSizes().absoluteArcWidths().
   199     absoluteNodeSizes().absoluteArcWidths().