CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes | Private Member Functions
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...
 
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_
 

Private Member Functions

 GraphWalker ()=delete
 

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 68 of file GraphWalker.h.

68  : graph_(g) { // complexity = (no nodes) * (no edges)
69  graph_.findRoots(root_);
70  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
71  if (!root_.empty()) {
72  queue_.push(root_[0]);
73  }
74  }

◆ 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 77 of file GraphWalker.h.

77  : graph_(g) {
78  index_result rr = graph_.nodeIndex(root);
79  if (!rr.second) // no such root node, no walker can be created!
80  throw root;
81 
82  root_.emplace_back(edge_type(rr.first, 0));
83  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
84  queue_.push(root_[0]);
85  }

◆ GraphWalker() [3/3]

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

Member Function Documentation

◆ current()

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

Definition at line 88 of file GraphWalker.h.

88  {
89  const edge_range &er = stack_.back();
90  return value_type(graph_.nodeData(er.first->first), graph_.edgeData(er.first->second));
91  }

Referenced by graph_combine().

◆ current_bfs()

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

Definition at line 94 of file GraphWalker.h.

94  {
95  const edge_type &e = queue_.front();
96  return value_type(graph_.nodeData(e.first), graph_.edgeData(e.second));
97  }

◆ firstChild()

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

Definition at line 110 of file GraphWalker.h.

110  {
111  result_type result = false;
112  const edge_range &adjEdges = graph_.edges(stack_.back().first->first);
113  if (adjEdges.first != adjEdges.second) {
114  stack_.emplace_back(adjEdges);
115  result = true;
116  }
117  return result;
118  }

◆ next()

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

Definition at line 142 of file GraphWalker.h.

142  {
143  result_type result = false;
144  if (firstChild()) {
145  result = true;
146  } else if (stack_.size() > 1 && nextSibling()) {
147  result = true;
148  } else {
149  while (parent()) {
150  if (stack_.size() > 1 && nextSibling()) {
151  result = true;
152  break;
153  }
154  }
155  }
156  return result;
157  }

Referenced by graph_combine().

◆ next_bfs()

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

Definition at line 160 of file GraphWalker.h.

160  {
161  result_type result(false);
162  if (!queue_.empty()) {
163  const edge_type &e = queue_.front();
164  const edge_range &er = graph_.edges(e.first);
165  const_edge_iterator it(er.first), ed(er.second);
166  for (; it != ed; ++it) {
167  queue_.push(*it);
168  }
169  queue_.pop();
170  if (!queue_.empty()) {
171  result = true;
172  }
173  }
174  return result;
175  }

◆ nextSibling()

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

Definition at line 121 of file GraphWalker.h.

121  {
122  result_type result = false;
123  edge_range &siblings = stack_.back();
124  if (siblings.first != (siblings.second - 1)) {
125  ++siblings.first;
126  result = true;
127  }
128  return result;
129  }

◆ parent()

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

Definition at line 132 of file GraphWalker.h.

132  {
133  result_type result = false;
134  if (stack_.size() > 1) {
135  stack_.pop_back();
136  result = true;
137  }
138  return result;
139  }

◆ reset()

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

Definition at line 100 of file GraphWalker.h.

100  {
101  stack_.clear();
102  stack_.emplace_back(edge_range(root_.begin(), root_.end()));
103  queue_.clear();
104  if (root_.size()) {
105  queue_.push(root_[0]);
106  }
107  }

◆ stack()

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

Definition at line 54 of file GraphWalker.h.

54 { return stack_; }

Referenced by graph_combine().

Member Data Documentation

◆ graph_

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

Definition at line 61 of file GraphWalker.h.

◆ queue_

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

Definition at line 59 of file GraphWalker.h.

◆ root_

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

Definition at line 60 of file GraphWalker.h.

◆ stack_

template<class N, class E>
stack_type math::GraphWalker< N, E >::stack_
protected
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
math::GraphWalker::stack_
stack_type stack_
Definition: GraphWalker.h:58
math::GraphWalker::graph_
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
math::GraphWalker::const_edge_iterator
typename math::Graph< N, E >::const_edge_iterator const_edge_iterator
Definition: GraphWalker.h:19
math::GraphWalker::firstChild
result_type firstChild()
Definition: GraphWalker.h:110
math::GraphWalker::value_type
typename math::Graph< N, E >::value_type value_type
Definition: GraphWalker.h:28
math::GraphWalker::edge_range
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
math::GraphWalker::result_type
bool result_type
Definition: GraphWalker.h:27
math::GraphWalker::queue_
bfs_type queue_
Definition: GraphWalker.h:59
root
Definition: RooFitFunction.h:10
math::GraphWalker::edge_type
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:16
math::GraphWalker::parent
result_type parent()
Definition: GraphWalker.h:132
math::GraphWalker::nextSibling
result_type nextSibling()
Definition: GraphWalker.h:121
math::GraphWalker::root_
edge_list root_
Definition: GraphWalker.h:60
mps_fire.result
result
Definition: mps_fire.py:311
math::GraphWalker::index_result
typename math::Graph< N, E >::index_result index_result
Definition: GraphWalker.h:15
g
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37