lemon/bits/extendable_graph_extender.h
author alpar
Mon, 20 Feb 2006 06:44:07 +0000
changeset 1974 191223f4b639
parent 1910 f95eea8c34b0
permissions -rw-r--r--
Public data members of xy became documented
alpar@1956
     1
/* -*- C++ -*-
alpar@1956
     2
 *
alpar@1956
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@1956
     4
 *
alpar@1956
     5
 * Copyright (C) 2003-2006
alpar@1956
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1956
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@1956
     8
 *
alpar@1956
     9
 * Permission to use, modify and distribute this software is granted
alpar@1956
    10
 * provided that this copyright notice appears in all copies. For
alpar@1956
    11
 * precise terms see the accompanying LICENSE file.
alpar@1956
    12
 *
alpar@1956
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@1956
    14
 * express or implied, and with no claim as to its suitability for any
alpar@1956
    15
 * purpose.
alpar@1956
    16
 *
alpar@1956
    17
 */
klao@946
    18
klao@946
    19
#ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946
    20
#define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946
    21
klao@946
    22
namespace lemon {
klao@946
    23
klao@946
    24
  template <typename _Base> 
klao@946
    25
  class ExtendableGraphExtender : public _Base {
klao@946
    26
  public:
klao@946
    27
klao@946
    28
    typedef ExtendableGraphExtender Graph;
klao@946
    29
    typedef _Base Parent;
klao@946
    30
klao@946
    31
    typedef typename Parent::Node Node;
klao@946
    32
    typedef typename Parent::Edge Edge;
klao@946
    33
klao@946
    34
    Node addNode() {
klao@946
    35
      Node node = Parent::addNode();
deba@1039
    36
      Parent::getNotifier(Node()).add(node);
klao@946
    37
      return node;
klao@946
    38
    }
klao@946
    39
    
klao@946
    40
    Edge addEdge(const Node& from, const Node& to) {
klao@946
    41
      Edge edge = Parent::addEdge(from, to);
deba@1039
    42
      Parent::getNotifier(Edge()).add(edge);
klao@946
    43
      return edge;
klao@946
    44
    }
klao@946
    45
klao@946
    46
  };
klao@946
    47
klao@1022
    48
  template <typename _Base> 
deba@1842
    49
  class ExtendableEdgeSetExtender : public _Base {
deba@1842
    50
  public:
deba@1842
    51
deba@1842
    52
    typedef ExtendableEdgeSetExtender Graph;
deba@1842
    53
    typedef _Base Parent;
deba@1842
    54
deba@1842
    55
    typedef typename Parent::Edge Edge;
deba@1842
    56
    typedef typename Parent::Node Node;
deba@1842
    57
deba@1842
    58
    Edge addEdge(const Node& from, const Node& to) {
deba@1842
    59
      Edge edge = Parent::addEdge(from, to);
deba@1842
    60
      Parent::getNotifier(Edge()).add(edge);
deba@1842
    61
      return edge;
deba@1842
    62
    }
deba@1842
    63
deba@1842
    64
  };
deba@1842
    65
deba@1842
    66
  template <typename _Base> 
klao@1909
    67
  class ExtendableUGraphExtender : public _Base {
klao@1022
    68
  public:
klao@1022
    69
klao@1909
    70
    typedef ExtendableUGraphExtender Graph;
klao@1022
    71
    typedef _Base Parent;
klao@1022
    72
klao@1022
    73
    typedef typename Parent::Node Node;
klao@1022
    74
    typedef typename Parent::Edge Edge;
klao@1909
    75
    typedef typename Parent::UEdge UEdge;
klao@1022
    76
klao@1022
    77
    Node addNode() {
klao@1022
    78
      Node node = Parent::addNode();
deba@1039
    79
      Parent::getNotifier(Node()).add(node);
klao@1022
    80
      return node;
klao@1022
    81
    }
klao@1022
    82
klao@1909
    83
    UEdge addEdge(const Node& from, const Node& to) {
klao@1909
    84
      UEdge uedge = Parent::addEdge(from, to);
klao@1909
    85
      Parent::getNotifier(UEdge()).add(uedge);
klao@1022
    86
deba@1414
    87
      std::vector<Edge> edges;
deba@1627
    88
      edges.push_back(Parent::direct(uedge, true));
deba@1627
    89
      edges.push_back(Parent::direct(uedge, false));
deba@1414
    90
      Parent::getNotifier(Edge()).add(edges);
klao@1022
    91
klao@1022
    92
      return uedge;
klao@1022
    93
    }
klao@1022
    94
klao@1022
    95
  };
klao@1022
    96
deba@1842
    97
  template <typename _Base> 
klao@1909
    98
  class ExtendableUEdgeSetExtender : public _Base {
deba@1842
    99
  public:
deba@1842
   100
klao@1909
   101
    typedef ExtendableUEdgeSetExtender Graph;
deba@1842
   102
    typedef _Base Parent;
deba@1842
   103
deba@1842
   104
    typedef typename Parent::Node Node;
deba@1842
   105
    typedef typename Parent::Edge Edge;
klao@1909
   106
    typedef typename Parent::UEdge UEdge;
deba@1842
   107
klao@1909
   108
    UEdge addEdge(const Node& from, const Node& to) {
klao@1909
   109
      UEdge uedge = Parent::addEdge(from, to);
klao@1909
   110
      Parent::getNotifier(UEdge()).add(uedge);
deba@1842
   111
deba@1842
   112
      std::vector<Edge> edges;
deba@1842
   113
      edges.push_back(Parent::direct(uedge, true));
deba@1842
   114
      edges.push_back(Parent::direct(uedge, false));
deba@1842
   115
      Parent::getNotifier(Edge()).add(edges);
deba@1842
   116
deba@1842
   117
      return uedge;
deba@1842
   118
    }
deba@1842
   119
deba@1842
   120
  };
deba@1842
   121
deba@1820
   122
deba@1820
   123
  template <typename _Base>
deba@1910
   124
  class ExtendableBpUGraphExtender : public _Base {
deba@1820
   125
  public:
deba@1820
   126
deba@1820
   127
    typedef _Base Parent;
deba@1910
   128
    typedef ExtendableBpUGraphExtender Graph;
deba@1820
   129
  
deba@1820
   130
    typedef typename Parent::Node Node;
deba@1910
   131
    typedef typename Parent::BNode BNode;
deba@1910
   132
    typedef typename Parent::ANode ANode;
deba@1820
   133
    typedef typename Parent::Edge Edge;
klao@1909
   134
    typedef typename Parent::UEdge UEdge;
deba@1820
   135
  
deba@1910
   136
    Node addANode() {
deba@1910
   137
      Node node = Parent::addANode();
deba@1910
   138
      Parent::getNotifier(ANode()).add(node);
deba@1820
   139
      Parent::getNotifier(Node()).add(node);
deba@1820
   140
      return node;
deba@1820
   141
    }
deba@1820
   142
deba@1910
   143
    Node addBNode() {
deba@1910
   144
      Node node = Parent::addBNode();
deba@1910
   145
      Parent::getNotifier(BNode()).add(node);
deba@1820
   146
      Parent::getNotifier(Node()).add(node);
deba@1820
   147
      return node;
deba@1820
   148
    }
deba@1820
   149
  
klao@1909
   150
    UEdge addEdge(const Node& source, const Node& target) {
klao@1909
   151
      UEdge uedge = Parent::addEdge(source, target);
klao@1909
   152
      Parent::getNotifier(UEdge()).add(uedge);
deba@1820
   153
    
deba@1820
   154
      std::vector<Edge> edges;
klao@1909
   155
      edges.push_back(Parent::direct(uedge, true));
klao@1909
   156
      edges.push_back(Parent::direct(uedge, false));
deba@1820
   157
      Parent::getNotifier(Edge()).add(edges);
deba@1820
   158
    
klao@1909
   159
      return uedge;
deba@1820
   160
    }
deba@1820
   161
deba@1820
   162
  };
deba@1820
   163
klao@946
   164
}
klao@946
   165
klao@946
   166
#endif