gparam.c
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
开发平台:

MultiPlatform

  1. #include <LEDA/graph.h>
  2. #include <LEDA/integer.h>
  3. #include <LEDA/real.h>
  4. #include <LEDA/vector.h>
  5. struct Simple1 {
  6.    string str;
  7. };
  8. void Print(const Simple1& x, ostream& out) { out << x.str; }
  9. struct Simple2 {
  10.    integer i;
  11. };
  12. void Print(const Simple2& x, ostream& out) { out << x.i; }
  13. struct Simple3 {
  14.    real r;
  15. Simple3(int i) { r = i; }
  16. Simple3() { r = 0; }
  17. };
  18. void Print(const Simple3& x, ostream& out) { out << x.r; }
  19. int main()
  20. {
  21.    GRAPH<Simple1,Simple2> G;
  22.    test_graph(G);
  23.    G.del_node(G.first_node());
  24.    G.print();
  25.    GRAPH<Simple1,Simple2> G1 = G;
  26.    vector vec(1.1,2.2,3.3);
  27.    node_array<Simple3> A(G1);
  28.    edge_array<vector>  B(G1,vec);
  29.    G1.print();
  30.    int i = 0;
  31.    node v;
  32.    forall_nodes(v,G1) A[v] = i++;
  33.    forall_nodes(v,G1) { Print(A[v],cout); cout << endl; }
  34.  
  35.    edge e;
  36.    forall_edges(e,G1)  cout << B[e] << endl;
  37.    return 0;
  38. }