Changeset 401:2d0cccf7cc94 in lemon0.x for src
 Timestamp:
 04/26/04 00:26:19 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@532
 Location:
 src/work/alpar
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/work/alpar/list_graph.h
r400 r401 16 16 class SymListGraph; 17 17 18 ///A smart graph class.18 ///A list graph class. 19 19 20 20 ///This is a simple and fast erasable graph implementation. … … 724 724 725 725 726 ///A smart graph class. 727 728 ///This is a simple and fast erasable graph implementation. 726 ///A graph class containing only nodes. 727 728 ///This class implements a graph structure without edges. 729 ///The most useful application of this class is to be the node set of an 730 ///\ref EdgeSet class. 729 731 /// 730 732 ///It conforms to the graph interface documented under 731 ///the description of \ref GraphSkeleton. 732 ///\sa \ref GraphSkeleton. 733 ///the description of \ref GraphSkeleton with the exception that you cannot 734 ///add (or delete) edges. The usual edge iterators are exists, but they are 735 ///always \ref INVALID. 736 ///\sa \ref GraphSkeleton 737 ///\se \ref EdgeSet 733 738 class NodeSet { 734 739 … … 1115 1120 1116 1121 1117 ///This is a simple and fast erasable graph implementation. 1122 ///Graph structure using a node set of another graph. 1123 1124 ///This structure can be used to establish another graph over a node set 1125 /// of an existing one. The node iterator will go through the nodes of the 1126 /// original graph, and the NodeMap's of both graphs will convert to 1127 /// each other. 1128 /// 1129 ///\param GG The type of the graph which shares its node set with this class. 1130 ///Its interface must conform with \ref GraphSkeleton. 1118 1131 /// 1119 1132 ///It conforms to the graph interface documented under 1120 1133 ///the description of \ref GraphSkeleton. 1121 1134 ///\sa \ref GraphSkeleton. 1135 ///\sa \ref NodeSet. 1122 1136 template<typename GG> 1123 1137 class EdgeSet { … … 1192 1206 public: 1193 1207 1194 EdgeSet( constNodeGraphType &_G) : G(_G),1195 1196 first_free_edge(1) {}1208 EdgeSet(NodeGraphType &_G) : G(_G), 1209 nodes(_G), edges(), 1210 first_free_edge(1) { } 1197 1211 EdgeSet(const EdgeSet &_g) : G(_g.G), nodes(_g.G), edges(_g.edges), 1198 first_free_edge(_g.first_free_edge) { }1212 first_free_edge(_g.first_free_edge) { } 1199 1213 1200 1214 ~EdgeSet() … … 1288 1302 } 1289 1303 1290 edges[n].tail = u .n; edges[n].head = v.n;1291 1292 edges[n].next_out = nodes[u .n].first_out;1293 if(nodes[u .n].first_out != 1) edges[nodes[u.n].first_out].prev_out = n;1294 edges[n].next_in = nodes[v .n].first_in;1295 if(nodes[v .n].first_in != 1) edges[nodes[v.n].first_in].prev_in = n;1304 edges[n].tail = u; edges[n].head = v; 1305 1306 edges[n].next_out = nodes[u].first_out; 1307 if(nodes[u].first_out != 1) edges[nodes[u].first_out].prev_out = n; 1308 edges[n].next_in = nodes[v].first_in; 1309 if(nodes[v].first_in != 1) edges[nodes[v].first_in].prev_in = n; 1296 1310 edges[n].prev_in = edges[n].prev_out = 1; 1297 1311 1298 nodes[u .n].first_out = nodes[v.n].first_in = n;1312 nodes[u].first_out = nodes[v].first_in = n; 1299 1313 1300 1314 Edge e; e.n=n; … … 1374 1388 NodeIt() : NodeGraphType::NodeIt() { } 1375 1389 NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {} 1376 NodeIt(const EdgeSet& _G) : NodeGraphType::Node (_G.G) { }1390 NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { } 1377 1391 NodeIt(const typename NodeGraphType::NodeIt &n) 1378 1392 : NodeGraphType::NodeIt(n) {} … … 1452 1466 ///\todo It can copy between different types. 1453 1467 /// 1454 template<typename TT> friend class NodeMap;1468 template<typename TT> 1455 1469 NodeMap(const typename NodeGraphType::NodeMap<TT> &m) 1456 1470 : NodeGraphType::NodeMap<T>(m) { } 
src/work/alpar/list_graph_demo.cc
r397 r401 121 121 122 122 } 123 124 // Tests for NodeSet and EdgeSet 125 126 { 127 NodeSet N; 128 129 typedef EdgeSet<NodeSet> ES; 130 131 ES E(N); 132 ES F(N); 133 for(int i=0;i<10;i++) G.addNode(); 134 135 for(ES::NodeIt n(E);E.valid(n);E.next(n)) 136 for(ES::NodeIt m(E);E.valid(m);E.next(m)) 137 if(n!=m) F.addEdge(n,m); 138 for(ES::NodeIt n(F);F.valid(n);F.next(n)) 139 for(ES::NodeIt m(F);F.valid(m);F.next(m)) 140 if(n<m) F.addEdge(n,m); 141 142 143 NodeSet::NodeMap<int> nm1(N); 144 ES::NodeMap<int> nm2(E); 145 ES::EdgeMap<int> eme(E); 146 ES::EdgeMap<int> emf(F); 147 148 149 } 123 150 124 151 }
Note: See TracChangeset
for help on using the changeset viewer.