embedding.c
资源名称:leda.tar.gz [点击查看]
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
源码类别:
数值算法/人工智能
开发平台:
MultiPlatform
- #include <LEDA/graph.h>
- #include <LEDA/graph_alg.h>
- main()
- {
- GRAPH<int,int> G;
- int n = read_int("n = ");
- random_planar_graph(G,n);
- list<edge> el = G.all_edges();
- edge e;
- forall(e,el) G.new_edge(target(e),source(e));
- if ( ! PLANAR(G,true) )
- { cout << "Graph is not planarn";
- exit(1);
- }
- node v;
- node_array<int> x(G),y(G);
- float T = used_time();
- cout << "OLD EMBEDDING ";
- cout.flush();
- STRAIGHT_LINE_EMBEDDING(G,x,y);
- cout << string("%6.2f sec n",used_time(T));
- cout << "NEW EMBEDDING ";
- cout.flush();
- STRAIGHT_LINE_EMBEDDING2(G,x,y);
- cout << string("%6.2f sec n",used_time(T));
- /*
- forall_nodes(v,G) cout << string("x = %2d y = %2dn",x[v],y[v]);
- */
- return 0;
- }