CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
math::GraphWalker< N, E > Class Template Reference

#include <GraphWalker.h>

Public Types

using bfs_type = std::queue< edge_type >
 
using const_edge_iterator = typename math::Graph< N, E >::const_edge_iterator
 
using edge_iterator = typename math::Graph< N, E >::edge_iterator
 
using edge_list = typename math::Graph< N, E >::edge_list
 
using edge_range = std::pair< const_edge_iterator, const_edge_iterator >
 
using edge_type = typename math::Graph< N, E >::edge_type
 
using index_result = typename math::Graph< N, E >::index_result
 
using index_type = typename math::Graph< N, E >::index_type
 
using result_type = bool
 
using stack_type = std::vector< edge_range >
 
using value_type = typename math::Graph< N, E >::value_type
 

Public Member Functions

value_type current () const
 
value_type current_bfs () const
 
result_type firstChild ()
 
 GraphWalker (const Graph< N, E > &)
 creates a walker rooted by the first candidate root found in the underlying Graph More...
 
 GraphWalker (const Graph< N, E > &, const N &)
 creates a walker rooted by the node given More...
 
 GraphWalker ()=delete
 
result_type next ()
 
result_type next_bfs ()
 
result_type nextSibling ()
 
result_type parent ()
 
void reset ()
 
const stack_typestack () const
 

Protected Attributes

const Graph< N, E > & graph_
 
bfs_type queue_
 
edge_list root_
 
stack_type stack_
 

Detailed Description

template<class N, class E>
class math::GraphWalker< N, E >

a walker for an acyclic directed multigraph

Definition at line 12 of file GraphWalker.h.

Member Typedef Documentation

◆ bfs_type

template<class N, class E>
using math::GraphWalker< N, E >::bfs_type = std::queue<edge_type>

Definition at line 25 of file GraphWalker.h.

◆ const_edge_iterator

template<class N, class E>
using math::GraphWalker< N, E >::const_edge_iterator = typename math::Graph<N, E>::const_edge_iterator

Definition at line 19 of file GraphWalker.h.

◆ edge_iterator

template<class N, class E>
using math::GraphWalker< N, E >::edge_iterator = typename math::Graph<N, E>::edge_iterator

Definition at line 18 of file GraphWalker.h.

◆ edge_list

template<class N, class E>
using math::GraphWalker< N, E >::edge_list = typename math::Graph<N, E>::edge_list

Definition at line 17 of file GraphWalker.h.

◆ edge_range

template<class N, class E>
using math::GraphWalker< N, E >::edge_range = std::pair<const_edge_iterator, const_edge_iterator>

Definition at line 22 of file GraphWalker.h.

◆ edge_type

template<class N, class E>
using math::GraphWalker< N, E >::edge_type = typename math::Graph<N, E>::edge_type

Definition at line 16 of file GraphWalker.h.

◆ index_result

template<class N, class E>
using math::GraphWalker< N, E >::index_result = typename math::Graph<N, E>::index_result

Definition at line 15 of file GraphWalker.h.

◆ index_type

template<class N, class E>
using math::GraphWalker< N, E >::index_type = typename math::Graph<N, E>::index_type

Definition at line 14 of file GraphWalker.h.

◆ result_type

template<class N, class E>
using math::GraphWalker< N, E >::result_type = bool

Definition at line 27 of file GraphWalker.h.

◆ stack_type

template<class N, class E>
using math::GraphWalker< N, E >::stack_type = std::vector<edge_range>

Definition at line 24 of file GraphWalker.h.

◆ value_type

template<class N, class E>
using math::GraphWalker< N, E >::value_type = typename math::Graph<N, E>::value_type

Definition at line 28 of file GraphWalker.h.

Constructor & Destructor Documentation

◆ GraphWalker() [1/3]

template<class N, class E>
math::GraphWalker< N, E >::GraphWalker ( const Graph< N, E > &  g)

creates a walker rooted by the first candidate root found in the underlying Graph

Definition at line 66 of file GraphWalker.h.

66  : graph_(g) { // complexity = (no nodes) * (no edges)
67  graph_.findRoots(root_);
68  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
69  if (!root_.empty()) {
70  queue_.push(root_[0]);
71  }
72  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:61

◆ GraphWalker() [2/3]

template<class N, class E>
math::GraphWalker< N, E >::GraphWalker ( const Graph< N, E > &  g,
const N root 
)

creates a walker rooted by the node given

Definition at line 75 of file GraphWalker.h.

75  : graph_(g) {
76  index_result rr = graph_.nodeIndex(root);
77  if (!rr.second) // no such root node, no walker can be created!
78  throw root;
79 
80  root_.emplace_back(edge_type(rr.first, 0));
81  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
82  queue_.push(root_[0]);
83  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
typename math::Graph< N, E >::index_result index_result
Definition: GraphWalker.h:15
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:16
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:61

◆ GraphWalker() [3/3]

template<class N, class E>
math::GraphWalker< N, E >::GraphWalker ( )
delete

Member Function Documentation

◆ current()

template<class N , class E >
GraphWalker< N, E >::value_type math::GraphWalker< N, E >::current ( ) const
inline

Definition at line 86 of file GraphWalker.h.

Referenced by HGCalWaferValidation::DDFindHGCal(), HGCalWaferValidation::DDFindWafers(), graph_combine(), and HGCalWaferValidation::ProcessWaferLayer().

86  {
87  const edge_range &er = stack_.back();
88  return value_type(graph_.nodeData(er.first->first), graph_.edgeData(er.first->second));
89  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
stack_type stack_
Definition: GraphWalker.h:59
typename math::Graph< N, E >::value_type value_type
Definition: GraphWalker.h:28
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22

◆ current_bfs()

template<class N , class E >
GraphWalker< N, E >::value_type math::GraphWalker< N, E >::current_bfs ( ) const

Definition at line 92 of file GraphWalker.h.

92  {
93  const edge_type &e = queue_.front();
94  return value_type(graph_.nodeData(e.first), graph_.edgeData(e.second));
95  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:16
typename math::Graph< N, E >::value_type value_type
Definition: GraphWalker.h:28

◆ firstChild()

template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::firstChild ( )

Definition at line 108 of file GraphWalker.h.

Referenced by HGCalWaferValidation::DDFindHGCal(), and HGCalWaferValidation::DDFindWafers().

108  {
109  result_type result = false;
110  const edge_range &adjEdges = graph_.edges(stack_.back().first->first);
111  if (adjEdges.first != adjEdges.second) {
112  stack_.emplace_back(adjEdges);
113  result = true;
114  }
115  return result;
116  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22

◆ next()

template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next ( void  )

Definition at line 140 of file GraphWalker.h.

Referenced by graph_combine().

140  {
141  result_type result = false;
142  if (firstChild()) {
143  result = true;
144  } else if (stack_.size() > 1 && nextSibling()) {
145  result = true;
146  } else {
147  while (parent()) {
148  if (stack_.size() > 1 && nextSibling()) {
149  result = true;
150  break;
151  }
152  }
153  }
154  return result;
155  }
stack_type stack_
Definition: GraphWalker.h:59
result_type parent()
Definition: GraphWalker.h:130
result_type firstChild()
Definition: GraphWalker.h:108
result_type nextSibling()
Definition: GraphWalker.h:119

◆ next_bfs()

template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next_bfs ( )

Definition at line 158 of file GraphWalker.h.

158  {
159  result_type result(false);
160  if (!queue_.empty()) {
161  const edge_type &e = queue_.front();
162  const edge_range &er = graph_.edges(e.first);
163  const_edge_iterator it(er.first), ed(er.second);
164  for (; it != ed; ++it) {
165  queue_.push(*it);
166  }
167  queue_.pop();
168  if (!queue_.empty()) {
169  result = true;
170  }
171  }
172  return result;
173  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:16
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
typename math::Graph< N, E >::const_edge_iterator const_edge_iterator
Definition: GraphWalker.h:19

◆ nextSibling()

template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::nextSibling ( )

Definition at line 119 of file GraphWalker.h.

Referenced by HGCalWaferValidation::DDFindHGCal(), HGCalWaferValidation::DDFindWafers(), and HGCalWaferValidation::ProcessWaferLayer().

119  {
120  result_type result = false;
121  edge_range &siblings = stack_.back();
122  if (siblings.first != (siblings.second - 1)) {
123  ++siblings.first;
124  result = true;
125  }
126  return result;
127  }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22

◆ parent()

template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::parent ( )

Definition at line 130 of file GraphWalker.h.

Referenced by HGCalWaferValidation::DDFindHGCal(), and HGCalWaferValidation::DDFindWafers().

130  {
131  result_type result = false;
132  if (stack_.size() > 1) {
133  stack_.pop_back();
134  result = true;
135  }
136  return result;
137  }
stack_type stack_
Definition: GraphWalker.h:59

◆ reset()

template<class N , class E >
void math::GraphWalker< N, E >::reset ( void  )

Definition at line 98 of file GraphWalker.h.

98  {
99  stack_.clear();
100  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
101  queue_.clear();
102  if (root_.size()) {
103  queue_.push(root_[0]);
104  }
105  }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:61

◆ stack()

template<class N, class E>
const stack_type& math::GraphWalker< N, E >::stack ( ) const
inline

Definition at line 55 of file GraphWalker.h.

Referenced by graph_combine().

55 { return stack_; }
stack_type stack_
Definition: GraphWalker.h:59

Member Data Documentation

◆ graph_

template<class N, class E>
const Graph<N, E>& math::GraphWalker< N, E >::graph_
protected

Definition at line 62 of file GraphWalker.h.

◆ queue_

template<class N, class E>
bfs_type math::GraphWalker< N, E >::queue_
protected

Definition at line 60 of file GraphWalker.h.

◆ root_

template<class N, class E>
edge_list math::GraphWalker< N, E >::root_
protected

Definition at line 61 of file GraphWalker.h.

◆ stack_

template<class N, class E>
stack_type math::GraphWalker< N, E >::stack_
protected