equal
deleted
inserted
replaced
20 #define LEMON_FULL_GRAPH_H |
20 #define LEMON_FULL_GRAPH_H |
21 |
21 |
22 #include <cmath> |
22 #include <cmath> |
23 |
23 |
24 |
24 |
25 #include <lemon/bits/iterable_graph_extender.h> |
|
26 #include <lemon/bits/alteration_notifier.h> |
|
27 #include <lemon/bits/static_map.h> |
|
28 #include <lemon/bits/graph_extender.h> |
25 #include <lemon/bits/graph_extender.h> |
|
26 |
29 |
27 |
30 #include <lemon/invalid.h> |
28 #include <lemon/invalid.h> |
31 #include <lemon/utility.h> |
29 #include <lemon/utility.h> |
32 |
30 |
33 |
31 |
189 if (edge.id % _nodeNum == 0) edge.id = -1; |
187 if (edge.id % _nodeNum == 0) edge.id = -1; |
190 } |
188 } |
191 |
189 |
192 }; |
190 }; |
193 |
191 |
194 typedef StaticMappableGraphExtender< |
192 typedef GraphExtender<FullGraphBase> ExtendedFullGraphBase; |
195 IterableGraphExtender< |
|
196 AlterableGraphExtender< |
|
197 GraphExtender<FullGraphBase> > > > ExtendedFullGraphBase; |
|
198 |
193 |
199 /// \ingroup graphs |
194 /// \ingroup graphs |
200 /// |
195 /// |
201 /// \brief A full graph class. |
196 /// \brief A full graph class. |
202 /// |
197 /// |
209 /// |
204 /// |
210 /// \author Alpar Juttner |
205 /// \author Alpar Juttner |
211 class FullGraph : public ExtendedFullGraphBase { |
206 class FullGraph : public ExtendedFullGraphBase { |
212 public: |
207 public: |
213 |
208 |
|
209 typedef ExtendedFullGraphBase Parent; |
|
210 |
|
211 /// \brief Constructor |
|
212 /// |
214 FullGraph(int n) { construct(n); } |
213 FullGraph(int n) { construct(n); } |
|
214 |
|
215 /// \brief Resize the graph |
|
216 /// |
|
217 void resize(int n) { |
|
218 Parent::getNotifier(Edge()).clear(); |
|
219 Parent::getNotifier(Node()).clear(); |
|
220 construct(n); |
|
221 Parent::getNotifier(Node()).build(); |
|
222 Parent::getNotifier(Edge()).build(); |
|
223 } |
215 }; |
224 }; |
216 |
225 |
217 |
226 |
218 class FullUGraphBase { |
227 class FullUGraphBase { |
219 int _nodeNum; |
228 int _nodeNum; |
377 edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); |
386 edge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); |
378 } |
387 } |
379 |
388 |
380 }; |
389 }; |
381 |
390 |
382 typedef StaticMappableUGraphExtender< |
391 typedef UGraphExtender<UGraphBaseExtender<FullUGraphBase> > |
383 IterableUGraphExtender< |
392 ExtendedFullUGraphBase; |
384 AlterableUGraphExtender< |
|
385 UGraphExtender<FullUGraphBase> > > > ExtendedFullUGraphBase; |
|
386 |
393 |
387 /// \ingroup graphs |
394 /// \ingroup graphs |
388 /// |
395 /// |
389 /// \brief An undirected full graph class. |
396 /// \brief An undirected full graph class. |
390 /// |
397 /// |
399 /// \sa FullGraph |
406 /// \sa FullGraph |
400 /// |
407 /// |
401 /// \author Balazs Dezso |
408 /// \author Balazs Dezso |
402 class FullUGraph : public ExtendedFullUGraphBase { |
409 class FullUGraph : public ExtendedFullUGraphBase { |
403 public: |
410 public: |
|
411 |
|
412 typedef ExtendedFullUGraphBase Parent; |
|
413 |
|
414 /// \brief Constructor |
404 FullUGraph(int n) { construct(n); } |
415 FullUGraph(int n) { construct(n); } |
|
416 |
|
417 /// \brief Resize the graph |
|
418 /// |
|
419 void resize(int n) { |
|
420 Parent::getNotifier(Edge()).clear(); |
|
421 Parent::getNotifier(UEdge()).clear(); |
|
422 Parent::getNotifier(Node()).clear(); |
|
423 construct(n); |
|
424 Parent::getNotifier(Node()).build(); |
|
425 Parent::getNotifier(UEdge()).build(); |
|
426 Parent::getNotifier(Edge()).build(); |
|
427 } |
405 }; |
428 }; |
406 |
429 |
407 |
430 |
408 class FullBpUGraphBase { |
431 class FullBpUGraphBase { |
409 protected: |
432 protected: |
575 } |
598 } |
576 |
599 |
577 }; |
600 }; |
578 |
601 |
579 |
602 |
580 typedef StaticMappableBpUGraphExtender< |
603 typedef BpUGraphExtender< BpUGraphBaseExtender< |
581 IterableBpUGraphExtender< |
604 FullBpUGraphBase> > ExtendedFullBpUGraphBase; |
582 AlterableBpUGraphExtender< |
|
583 BpUGraphExtender < |
|
584 FullBpUGraphBase> > > > |
|
585 ExtendedFullBpUGraphBase; |
|
586 |
605 |
587 |
606 |
588 /// \ingroup graphs |
607 /// \ingroup graphs |
589 /// |
608 /// |
590 /// \brief An undirected full bipartite graph class. |
609 /// \brief An undirected full bipartite graph class. |
597 /// |
616 /// |
598 /// \author Balazs Dezso |
617 /// \author Balazs Dezso |
599 class FullBpUGraph : |
618 class FullBpUGraph : |
600 public ExtendedFullBpUGraphBase { |
619 public ExtendedFullBpUGraphBase { |
601 public: |
620 public: |
|
621 |
602 typedef ExtendedFullBpUGraphBase Parent; |
622 typedef ExtendedFullBpUGraphBase Parent; |
|
623 |
603 FullBpUGraph(int aNodeNum, int bNodeNum) { |
624 FullBpUGraph(int aNodeNum, int bNodeNum) { |
604 Parent::construct(aNodeNum, bNodeNum); |
625 Parent::construct(aNodeNum, bNodeNum); |
605 } |
626 } |
|
627 /// \brief Resize the graph |
|
628 /// |
|
629 void resize(int n, int m) { |
|
630 Parent::getNotifier(Edge()).clear(); |
|
631 Parent::getNotifier(UEdge()).clear(); |
|
632 Parent::getNotifier(Node()).clear(); |
|
633 construct(n, m); |
|
634 Parent::getNotifier(Node()).build(); |
|
635 Parent::getNotifier(UEdge()).build(); |
|
636 Parent::getNotifier(Edge()).build(); |
|
637 } |
606 }; |
638 }; |
607 |
639 |
608 } //namespace lemon |
640 } //namespace lemon |
609 |
641 |
610 |
642 |