MineLink
 All Data Structures Functions Variables Pages
graph.h
1 #ifndef __GRAPH_H__
2 #define __GRAPH_H__
3 #include "../../data_structures/bm/blockmodel.h"
4 #include "../../problems/finalpit/fp.h"
5 #include <deque>
6 
7 using std::vector;
8 using std::map;
9 
10 
11 namespace delphos{
12 
13 
14 
19 private:
20 
21  #ifdef ARCH32
22  typedef double value_type; //unsigned int
23  #else
24  typedef double value_type; //unsigned int
25  #endif
26 
27  struct node;
28 
29  typedef struct arc
30  {
31  struct node* _from;
32  struct node* _to;
33 
34  value_type _flow;
35  value_type _capacity;
36  unsigned short _reversed_status;
37  } FlowArc;
38 
39  typedef struct node
40  {
41  struct node* _parent;
42  struct node* _child_list;
43  struct node* _last_scan;
44  struct node* _neighbour; // neighbour in strong root list
45  struct arc* _arc_to_parent;
46 
47  vector<FlowArc*> _out_of_tree; // residual graph
48 
49  value_type _excess;
50 
51  BlockIndexType _last_out_of_tree_arc_index;
52  BlockIndexType _index;
53  BlockIndexType _label; // that label is a distance from the sink
54 
55  bool _in_min_cut_root_set;
56 
57  } Node;
58 
59 
60  BlockIndexType _nb_nodes;
61  BlockIndexType _nb_arcs;
62  BlockIndexType _source;
63  BlockIndexType _sink;
64 
65  Node* _node_list;
66  FlowArc* _arc_list;
67  map<BlockIndexType, deque<BlockIndexType> > _strong_root_buckets;
68  BlockIndexType _highest_strong_label_value;
69  BlockIndexType* _label_value_count; //for all nodes - {source,sink}
70 
71  string _value_attr;
72  BlockSelection* _min_cut_root_set;
73  BlockIndexType _nb_prec_arcs;
74  unsigned int _default_nblevel;
75  double _default_ang;
76 
77  void InitGraph(const FinalPitInstance& fpi);
78  void InitPseudoFlow();
79  Node* GetHighestStrongRoot();
80  void PutBranchInMinCutRootSet(Node* pnode);
81  void SetMinCutRootSet();
82  FlowArc* FindMergerArc(Node* pnode,bool& to_strong_direction);
83  void AddParentalRelationship(Node* pchild,Node* pnew_parent);
84  void CutParentalRelationship(Node* pchild,Node* pold_parent);
85  void MergeSubTrees(Node* pparent, Node* pchild, FlowArc* pnew_arc);
86  void PushExcess(Node* pstrong);
87  void AddRootToBucket(const BlockIndexType& index,const BlockIndexType& label);
88  void Relabel(Node* pnode);
89  void CreateArcs(const FinalPitInstance& fpi);
90 
91 public:
98  MinCutGraph(const FinalPitInstance& fpi,string value_attr);
99 
108  MinCutGraph(const FinalPitInstance& fpi,string value_attr,const double& angle,const unsigned int& nblevel);
109 
113  ~MinCutGraph();
114 
118  bool PseudoFlow();
119 
124 };
125 
126 }
127 #endif
Abstracts a set of blocks (subset of a blockmodel).
Definition: blocksel.h:33
Defines a case for the final pit problem.
Definition: fp.h:21
BlockSelection * GetMinCutRootSet()
Retrieves the minimum cut root set that corresponds to final pit set.
Definition: graph.cpp:531
bool PseudoFlow()
Implementation of the Pseudoflow algorithm.
Definition: graph.cpp:260
~MinCutGraph()
Destructor.
Definition: graph.cpp:229
MinCutGraph(const FinalPitInstance &fpi, string value_attr)
Creates a new graph based on a given instance.
Definition: graph.cpp:12
An implementation of the graph used by the final pit solver based on the Pseudoflow algorithm to solv...
Definition: graph.h:18