gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Doc improvements in HaoOrlin (#398)
0 1 0
default
1 file changed with 21 insertions and 11 deletions:
↑ Collapse diff ↑
Ignore white space 48 line context
... ...
@@ -32,50 +32,50 @@
32 32
/// \brief Implementation of the Hao-Orlin algorithm.
33 33
///
34 34
/// Implementation of the Hao-Orlin algorithm for finding a minimum cut
35 35
/// in a digraph.
36 36

	
37 37
namespace lemon {
38 38

	
39 39
  /// \ingroup min_cut
40 40
  ///
41 41
  /// \brief Hao-Orlin algorithm for finding a minimum cut in a digraph.
42 42
  ///
43 43
  /// This class implements the Hao-Orlin algorithm for finding a minimum
44 44
  /// value cut in a directed graph \f$D=(V,A)\f$.
45 45
  /// It takes a fixed node \f$ source \in V \f$ and
46 46
  /// consists of two phases: in the first phase it determines a
47 47
  /// minimum cut with \f$ source \f$ on the source-side (i.e. a set
48 48
  /// \f$ X\subsetneq V \f$ with \f$ source \in X \f$ and minimal outgoing
49 49
  /// capacity) and in the second phase it determines a minimum cut
50 50
  /// with \f$ source \f$ on the sink-side (i.e. a set
51 51
  /// \f$ X\subsetneq V \f$ with \f$ source \notin X \f$ and minimal outgoing
52 52
  /// capacity). Obviously, the smaller of these two cuts will be a
53 53
  /// minimum cut of \f$ D \f$. The algorithm is a modified
54 54
  /// preflow push-relabel algorithm. Our implementation calculates
55 55
  /// the minimum cut in \f$ O(n^2\sqrt{m}) \f$ time (we use the
56
  /// highest-label rule), or in \f$O(nm)\f$ for unit capacities. The
57
  /// purpose of such algorithm is e.g. testing network reliability.
56
  /// highest-label rule), or in \f$O(nm)\f$ for unit capacities. A notable
57
  /// use of this algorithm is testing network reliability.
58 58
  ///
59 59
  /// For an undirected graph you can run just the first phase of the
60 60
  /// algorithm or you can use the algorithm of Nagamochi and Ibaraki,
61 61
  /// which solves the undirected problem in \f$ O(nm + n^2 \log n) \f$
62 62
  /// time. It is implemented in the NagamochiIbaraki algorithm class.
63 63
  ///
64 64
  /// \tparam GR The type of the digraph the algorithm runs on.
65 65
  /// \tparam CAP The type of the arc map containing the capacities,
66 66
  /// which can be any numreric type. The default map type is
67 67
  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
68 68
  /// \tparam TOL Tolerance class for handling inexact computations. The
69 69
  /// default tolerance type is \ref Tolerance "Tolerance<CAP::Value>".
70 70
#ifdef DOXYGEN
71 71
  template <typename GR, typename CAP, typename TOL>
72 72
#else
73 73
  template <typename GR,
74 74
            typename CAP = typename GR::template ArcMap<int>,
75 75
            typename TOL = Tolerance<typename CAP::Value> >
76 76
#endif
77 77
  class HaoOrlin {
78 78
  public:
79 79

	
80 80
    /// The digraph type of the algorithm
81 81
    typedef GR Digraph;
... ...
@@ -891,115 +891,125 @@
891 891
      }
892 892
      if (!_bucket) {
893 893
        _bucket = new typename Digraph::template NodeMap<int>(_graph);
894 894
      }
895 895
      if (!_excess) {
896 896
        _excess = new ExcessMap(_graph);
897 897
      }
898 898
      if (!_source_set) {
899 899
        _source_set = new SourceSetMap(_graph);
900 900
      }
901 901
      if (!_min_cut_map) {
902 902
        _min_cut_map = new MinCutMap(_graph);
903 903
      }
904 904

	
905 905
      _min_cut = std::numeric_limits<Value>::max();
906 906
    }
907 907

	
908 908

	
909 909
    /// \brief Calculate a minimum cut with \f$ source \f$ on the
910 910
    /// source-side.
911 911
    ///
912 912
    /// This function calculates a minimum cut with \f$ source \f$ on the
913 913
    /// source-side (i.e. a set \f$ X\subsetneq V \f$ with
914 914
    /// \f$ source \in X \f$ and minimal outgoing capacity).
915
    /// It updates the stored cut if (and only if) the newly found one
916
    /// is better.
915 917
    ///
916 918
    /// \pre \ref init() must be called before using this function.
917 919
    void calculateOut() {
918 920
      findMinCutOut();
919 921
    }
920 922

	
921 923
    /// \brief Calculate a minimum cut with \f$ source \f$ on the
922 924
    /// sink-side.
923 925
    ///
924 926
    /// This function calculates a minimum cut with \f$ source \f$ on the
925 927
    /// sink-side (i.e. a set \f$ X\subsetneq V \f$ with
926 928
    /// \f$ source \notin X \f$ and minimal outgoing capacity).
929
    /// It updates the stored cut if (and only if) the newly found one
930
    /// is better.
927 931
    ///
928 932
    /// \pre \ref init() must be called before using this function.
929 933
    void calculateIn() {
930 934
      findMinCutIn();
931 935
    }
932 936

	
933 937

	
934 938
    /// \brief Run the algorithm.
935 939
    ///
936
    /// This function runs the algorithm. It finds nodes \c source and
937
    /// \c target arbitrarily and then calls \ref init(), \ref calculateOut()
940
    /// This function runs the algorithm. It chooses source node,
941
    /// then calls \ref init(), \ref calculateOut()
938 942
    /// and \ref calculateIn().
939 943
    void run() {
940 944
      init();
941 945
      calculateOut();
942 946
      calculateIn();
943 947
    }
944 948

	
945 949
    /// \brief Run the algorithm.
946 950
    ///
947
    /// This function runs the algorithm. It uses the given \c source node,
948
    /// finds a proper \c target node and then calls the \ref init(),
949
    /// \ref calculateOut() and \ref calculateIn().
951
    /// This function runs the algorithm. It calls \ref init(),
952
    /// \ref calculateOut() and \ref calculateIn() with the given
953
    /// source node.
950 954
    void run(const Node& s) {
951 955
      init(s);
952 956
      calculateOut();
953 957
      calculateIn();
954 958
    }
955 959

	
956 960
    /// @}
957 961

	
958 962
    /// \name Query Functions
959 963
    /// The result of the %HaoOrlin algorithm
960 964
    /// can be obtained using these functions.\n
961 965
    /// \ref run(), \ref calculateOut() or \ref calculateIn()
962 966
    /// should be called before using them.
963 967

	
964 968
    /// @{
965 969

	
966 970
    /// \brief Return the value of the minimum cut.
967 971
    ///
968
    /// This function returns the value of the minimum cut.
972
    /// This function returns the value of the best cut found by the
973
    /// previously called \ref run(), \ref calculateOut() or \ref
974
    /// calculateIn().
969 975
    ///
970 976
    /// \pre \ref run(), \ref calculateOut() or \ref calculateIn()
971 977
    /// must be called before using this function.
972 978
    Value minCutValue() const {
973 979
      return _min_cut;
974 980
    }
975 981

	
976 982

	
977 983
    /// \brief Return a minimum cut.
978 984
    ///
979
    /// This function sets \c cutMap to the characteristic vector of a
980
    /// minimum value cut: it will give a non-empty set \f$ X\subsetneq V \f$
981
    /// with minimal outgoing capacity (i.e. \c cutMap will be \c true exactly
985
    /// This function gives the best cut found by the
986
    /// previously called \ref run(), \ref calculateOut() or \ref
987
    /// calculateIn().
988
    ///
989
    /// It sets \c cutMap to the characteristic vector of the found
990
    /// minimum value cut - a non-empty set \f$ X\subsetneq V \f$
991
    /// of minimum outgoing capacity (i.e. \c cutMap will be \c true exactly
982 992
    /// for the nodes of \f$ X \f$).
983 993
    ///
984 994
    /// \param cutMap A \ref concepts::WriteMap "writable" node map with
985 995
    /// \c bool (or convertible) value type.
986 996
    ///
987 997
    /// \return The value of the minimum cut.
988 998
    ///
989 999
    /// \pre \ref run(), \ref calculateOut() or \ref calculateIn()
990 1000
    /// must be called before using this function.
991 1001
    template <typename CutMap>
992 1002
    Value minCutMap(CutMap& cutMap) const {
993 1003
      for (NodeIt it(_graph); it != INVALID; ++it) {
994 1004
        cutMap.set(it, (*_min_cut_map)[it]);
995 1005
      }
996 1006
      return _min_cut;
997 1007
    }
998 1008

	
999 1009
    /// @}
1000 1010

	
1001 1011
  }; //class HaoOrlin
1002 1012

	
1003 1013
} //namespace lemon
1004 1014

	
1005 1015
#endif //LEMON_HAO_ORLIN_H
0 comments (0 inline)