211 |
211 |
212 FullGraph(int n) { construct(n); } |
212 FullGraph(int n) { construct(n); } |
213 }; |
213 }; |
214 |
214 |
215 |
215 |
216 class UndirFullGraphBase { |
216 class FullUGraphBase { |
217 int _nodeNum; |
217 int _nodeNum; |
218 int _edgeNum; |
218 int _edgeNum; |
219 public: |
219 public: |
220 |
220 |
221 typedef UndirFullGraphBase Graph; |
221 typedef FullUGraphBase Graph; |
222 |
222 |
223 class Node; |
223 class Node; |
224 class Edge; |
224 class Edge; |
225 |
225 |
226 public: |
226 public: |
227 |
227 |
228 UndirFullGraphBase() {} |
228 FullUGraphBase() {} |
229 |
229 |
230 |
230 |
231 ///Creates a full graph with \c n nodes. |
231 ///Creates a full graph with \c n nodes. |
232 void construct(int n) { _nodeNum = n; _edgeNum = n * (n - 1) / 2; } |
232 void construct(int n) { _nodeNum = n; _edgeNum = n * (n - 1) / 2; } |
233 /// |
233 /// |
375 edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); |
375 edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); |
376 } |
376 } |
377 |
377 |
378 }; |
378 }; |
379 |
379 |
380 typedef StaticMappableUndirGraphExtender< |
380 typedef StaticMappableUGraphExtender< |
381 IterableUndirGraphExtender< |
381 IterableUGraphExtender< |
382 AlterableUndirGraphExtender< |
382 AlterableUGraphExtender< |
383 UndirGraphExtender<UndirFullGraphBase> > > > ExtendedUndirFullGraphBase; |
383 UGraphExtender<FullUGraphBase> > > > ExtendedFullUGraphBase; |
384 |
384 |
385 /// \ingroup graphs |
385 /// \ingroup graphs |
386 /// |
386 /// |
387 /// \brief An undirected full graph class. |
387 /// \brief An undirected full graph class. |
388 /// |
388 /// |
389 /// This is a simple and fast undirected full graph implementation. |
389 /// This is a simple and fast undirected full graph implementation. |
390 /// It is completely static, so you can neither add nor delete either |
390 /// It is completely static, so you can neither add nor delete either |
391 /// edges or nodes. |
391 /// edges or nodes. |
392 /// |
392 /// |
393 /// The main difference beetween the \e FullGraph and \e UndirFullGraph class |
393 /// The main difference beetween the \e FullGraph and \e FullUGraph class |
394 /// is that this class conforms to the undirected graph concept and |
394 /// is that this class conforms to the undirected graph concept and |
395 /// it does not contain the loop edges. |
395 /// it does not contain the loop edges. |
396 /// |
396 /// |
397 /// \sa FullGraph |
397 /// \sa FullGraph |
398 /// |
398 /// |
399 /// \author Balazs Dezso |
399 /// \author Balazs Dezso |
400 class UndirFullGraph : public ExtendedUndirFullGraphBase { |
400 class FullUGraph : public ExtendedFullUGraphBase { |
401 public: |
401 public: |
402 UndirFullGraph(int n) { construct(n); } |
402 FullUGraph(int n) { construct(n); } |
403 }; |
403 }; |
404 |
404 |
405 |
405 |
406 class FullUndirBipartiteGraphBase { |
406 class FullUBipartiteGraphBase { |
407 protected: |
407 protected: |
408 |
408 |
409 int _upperNodeNum; |
409 int _upperNodeNum; |
410 int _lowerNodeNum; |
410 int _lowerNodeNum; |
411 |
411 |
413 |
413 |
414 public: |
414 public: |
415 |
415 |
416 class NodeSetError : public LogicError { |
416 class NodeSetError : public LogicError { |
417 virtual const char* exceptionName() const { |
417 virtual const char* exceptionName() const { |
418 return "lemon::FullUndirBipartiteGraph::NodeSetError"; |
418 return "lemon::FullUBipartiteGraph::NodeSetError"; |
419 } |
419 } |
420 }; |
420 }; |
421 |
421 |
422 class Node { |
422 class Node { |
423 friend class FullUndirBipartiteGraphBase; |
423 friend class FullUBipartiteGraphBase; |
424 protected: |
424 protected: |
425 int id; |
425 int id; |
426 |
426 |
427 Node(int _id) : id(_id) {} |
427 Node(int _id) : id(_id) {} |
428 public: |
428 public: |
573 } |
573 } |
574 |
574 |
575 }; |
575 }; |
576 |
576 |
577 |
577 |
578 typedef StaticMappableUndirBipartiteGraphExtender< |
578 typedef StaticMappableUBipartiteGraphExtender< |
579 IterableUndirBipartiteGraphExtender< |
579 IterableUBipartiteGraphExtender< |
580 AlterableUndirBipartiteGraphExtender< |
580 AlterableUBipartiteGraphExtender< |
581 UndirBipartiteGraphExtender < |
581 UBipartiteGraphExtender < |
582 FullUndirBipartiteGraphBase> > > > |
582 FullUBipartiteGraphBase> > > > |
583 ExtendedFullUndirBipartiteGraphBase; |
583 ExtendedFullUBipartiteGraphBase; |
584 |
584 |
585 |
585 |
586 class FullUndirBipartiteGraph : |
586 class FullUBipartiteGraph : |
587 public ExtendedFullUndirBipartiteGraphBase { |
587 public ExtendedFullUBipartiteGraphBase { |
588 public: |
588 public: |
589 typedef ExtendedFullUndirBipartiteGraphBase Parent; |
589 typedef ExtendedFullUBipartiteGraphBase Parent; |
590 FullUndirBipartiteGraph(int upperNodeNum, int lowerNodeNum) { |
590 FullUBipartiteGraph(int upperNodeNum, int lowerNodeNum) { |
591 Parent::construct(upperNodeNum, lowerNodeNum); |
591 Parent::construct(upperNodeNum, lowerNodeNum); |
592 } |
592 } |
593 }; |
593 }; |
594 |
594 |
595 } //namespace lemon |
595 } //namespace lemon |