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

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

Definition at line 26 of file GraphWalker.h.

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

Definition at line 20 of file GraphWalker.h.

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

Definition at line 19 of file GraphWalker.h.

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

Definition at line 18 of file GraphWalker.h.

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

Definition at line 23 of file GraphWalker.h.

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

Definition at line 17 of file GraphWalker.h.

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

Definition at line 16 of file GraphWalker.h.

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

Definition at line 15 of file GraphWalker.h.

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

Definition at line 28 of file GraphWalker.h.

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

Definition at line 25 of file GraphWalker.h.

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

Definition at line 29 of file GraphWalker.h.

Constructor & Destructor Documentation

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

References math::GraphWalker< N, E >::graph_, math::GraphWalker< N, E >::queue_, math::GraphWalker< N, E >::root_, and math::GraphWalker< N, E >::stack_.

70  : graph_(g)
71 { // complexity = (no nodes) * (no edges)
72  graph_.findRoots(root_);
73  stack_.emplace_back(edge_range(root_.begin(),root_.end()));
74  if (!root_.empty()) {
75  queue_.push(root_[0]);
76  }
77 }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
edge_list root_
Definition: GraphWalker.h:61
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
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 80 of file GraphWalker.h.

References math::GraphWalker< N, E >::graph_, math::GraphWalker< N, E >::queue_, pyrootRender::root, math::GraphWalker< N, E >::root_, findQualityFiles::rr, and math::GraphWalker< N, E >::stack_.

81  : graph_(g)
82 {
83  index_result rr = graph_.nodeIndex(root);
84  if (!rr.second) // no such root node, no walker can be created!
85  throw root;
86 
87  root_.emplace_back(edge_type(rr.first, 0));
88  stack_.emplace_back(edge_range(root_.begin(),root_.end()));
89  queue_.push(root_[0]);
90 }
typename math::Graph< N, E >::index_result index_result
Definition: GraphWalker.h:16
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:17
edge_list root_
Definition: GraphWalker.h:61
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
template<class N, class E>
math::GraphWalker< N, E >::GraphWalker ( )
privatedelete

Member Function Documentation

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

Definition at line 93 of file GraphWalker.h.

References math::GraphWalker< N, E >::graph_, and math::GraphWalker< N, E >::stack_.

Referenced by TGeoFromDddService::createManager(), graph_combine(), graph_tree_output(), and output().

94 {
95  const edge_range & er = stack_.back();
96  return value_type(graph_.nodeData(er.first->first), graph_.edgeData(er.first->second));
97 }
typename math::Graph< N, E >::value_type value_type
Definition: GraphWalker.h:29
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
template<class N , class E >
GraphWalker< N, E >::value_type math::GraphWalker< N, E >::current_bfs ( ) const

Definition at line 100 of file GraphWalker.h.

References MillePedeFileConverter_cfg::e, math::GraphWalker< N, E >::graph_, and math::GraphWalker< N, E >::queue_.

101 {
102  const edge_type & e = queue_.front();
103  return value_type(graph_.nodeData(e.first), graph_.edgeData(e.second));
104 }
typename math::Graph< N, E >::value_type value_type
Definition: GraphWalker.h:29
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:17
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::firstChild ( )

Definition at line 118 of file GraphWalker.h.

References math::GraphWalker< N, E >::graph_, mps_fire::result, and math::GraphWalker< N, E >::stack_.

Referenced by graph_tree_output(), and math::GraphWalker< N, E >::next().

119 {
120  result_type result = false;
121  const edge_range & adjEdges
122  = graph_.edges(stack_.back().first->first);
123  if (adjEdges.first != adjEdges.second) {
124  stack_.emplace_back(adjEdges);
125  result = true;
126  }
127  return result;
128 }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next ( void  )

Definition at line 154 of file GraphWalker.h.

References math::GraphWalker< N, E >::firstChild(), math::GraphWalker< N, E >::nextSibling(), math::GraphWalker< N, E >::parent(), mps_fire::result, and math::GraphWalker< N, E >::stack_.

Referenced by graph_combine(), and output().

155 {
156  result_type result = false;
157  if (firstChild()) {
158  result = true;
159  }
160  else if(stack_.size()>1 && nextSibling()) {
161  result = true;
162  }
163  else {
164  while(parent()) {
165  if(stack_.size()>1 && nextSibling()) {
166  result = true;
167  break;
168  }
169  }
170  }
171  return result;
172 }
stack_type stack_
Definition: GraphWalker.h:59
result_type parent()
Definition: GraphWalker.h:143
result_type firstChild()
Definition: GraphWalker.h:118
result_type nextSibling()
Definition: GraphWalker.h:131
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next_bfs ( )

Definition at line 175 of file GraphWalker.h.

References MillePedeFileConverter_cfg::e, math::GraphWalker< N, E >::graph_, math::GraphWalker< N, E >::queue_, and mps_fire::result.

176 {
177  result_type result(false);
178  if (!queue_.empty()) {
179  const edge_type & e = queue_.front();
180  const edge_range & er = graph_.edges(e.first);
181  const_edge_iterator it(er.first), ed(er.second);
182  for (; it != ed; ++it) {
183  queue_.push(*it);
184  }
185  queue_.pop();
186  if (!queue_.empty()) {
187  result=true;
188  }
189  }
190  return result;
191 }
typename math::Graph< N, E >::const_edge_iterator const_edge_iterator
Definition: GraphWalker.h:20
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
typename math::Graph< N, E >::edge_type edge_type
Definition: GraphWalker.h:17
const Graph< N, E > & graph_
Definition: GraphWalker.h:62
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::nextSibling ( )

Definition at line 131 of file GraphWalker.h.

References mps_fire::result, and math::GraphWalker< N, E >::stack_.

Referenced by graph_tree_output(), and math::GraphWalker< N, E >::next().

132 {
133  result_type result = false;
134  edge_range & siblings = stack_.back();
135  if (siblings.first != (siblings.second - 1) ) {
136  ++siblings.first;
137  result = true;
138  }
139  return result;
140 }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::parent ( )

Definition at line 143 of file GraphWalker.h.

References mps_fire::result, and math::GraphWalker< N, E >::stack_.

Referenced by Vispa.Gui.ConnectableWidget.ConnectableWidget::addMenuEntry(), Vispa.Views.LineDecayView.LineDecayContainer::applyFilter(), Vispa.Views.BoxDecayView.BoxDecayContainer::arrangeUsingRelations(), Vispa.Views.BoxDecayView.BoxDecayContainer::autolayoutAlgorithm(), Vispa.Gui.ZoomableScrollableWidgetOwner.ZoomableScrollableWidgetOwner::autosizeScrollArea(), Vispa.Views.BoxDecayView.BoxDecayContainer::autosizeScrollArea(), Vispa.Gui.PortWidget.PortWidget::connectionPoint(), Vispa.Main.StartupScreen.StartupScreen::createDescriptionWidget(), Vispa.Views.BoxDecayView.BoxDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.DecayLine::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::delete(), Vispa.Views.LineDecayView.DecayNode::delete(), Vispa.Views.LineDecayView.DecayLine::delete(), Vispa.Gui.VispaWidget.VispaWidget::delete(), Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), Vispa.Share.ImageExporter.ImageExporter::exportImageDialog(), Vispa.Views.LineDecayView.DecayLine::extendedSize(), graph_tree_output(), Vispa.Gui.VispaWidget.VispaWidget::keyPressEvent(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), Vispa.Gui.PortWidget.PortWidget::moduleParent(), Vispa.Gui.WidgetContainer.WidgetContainer::mouseDoubleClickEvent(), Vispa.Gui.VispaWidget.VispaWidget::mouseDoubleClickEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.LineDecayView.ParticleWidget::mousePressEvent(), Vispa.Views.LineDecayView.DecayNode::move(), math::GraphWalker< N, E >::next(), Vispa.Views.LineDecayView.LineDecayContainer::noDecorationsMode(), Vispa.Views.LineDecayView.LineDecayContainer::operationId(), Vispa.Views.LineDecayView.DecayLine::paint(), Vispa.Gui.VispaWidget.VispaWidget::paintEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::positionizeMenuWidget(), Vispa.Views.LineDecayView.DecayLine::qtLineStyle(), Vispa.Views.WidgetView.WidgetView::restoreSelection(), Vispa.Views.WidgetView.WidgetView::select(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Views.LineDecayView.LineDecayContainer::sizeHint(), Vispa.Views.LineDecayView.LineDecayContainer::tabController(), Vispa.Views.BoxDecayView.BoxDecayContainer::toggleCollapsed(), Vispa.Views.LineDecayView.DecayNode::unite(), Vispa.Views.PropertyView.PropertyView::valueChanged(), Vispa.Views.BoxDecayView.BoxDecayContainer::widgetByObject(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDoubleClicked(), and Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDragged().

144 {
145  result_type result = false;
146  if (stack_.size()>1) {
147  stack_.pop_back();
148  result = true;
149  }
150  return result;
151 }
stack_type stack_
Definition: GraphWalker.h:59
template<class N , class E >
void math::GraphWalker< N, E >::reset ( void  )

Definition at line 107 of file GraphWalker.h.

References math::GraphWalker< N, E >::queue_, math::GraphWalker< N, E >::root_, and math::GraphWalker< N, E >::stack_.

108 {
109  stack_.clear();
110  stack_.emplace_back(edge_range(root_.begin(),root_.end()));
111  queue_.clear();
112  if (root_.size()) {
113  queue_.push(root_[0]);
114  }
115 }
stack_type stack_
Definition: GraphWalker.h:59
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:23
edge_list root_
Definition: GraphWalker.h:61
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(), and graph_tree_output().

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

Member Data Documentation

template<class N, class E>
const Graph<N,E>& math::GraphWalker< N, E >::graph_
protected
template<class N, class E>
bfs_type math::GraphWalker< N, E >::queue_
protected
template<class N, class E>
edge_list math::GraphWalker< N, E >::root_
protected
template<class N, class E>
stack_type math::GraphWalker< N, E >::stack_
protected