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 25 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 19 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 18 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 17 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 22 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 16 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 15 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 14 of file GraphWalker.h.

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

Definition at line 27 of file GraphWalker.h.

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

Definition at line 24 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 28 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 68 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_.

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  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
stack_type stack_
Definition: GraphWalker.h:58
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:60
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.

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

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  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
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
stack_type stack_
Definition: GraphWalker.h:58
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:60
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 88 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().

88  {
89  const edge_range &er = stack_.back();
90  return value_type(graph_.nodeData(er.first->first), graph_.edgeData(er.first->second));
91  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
stack_type stack_
Definition: GraphWalker.h:58
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
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.

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

94  {
95  const edge_type &e = queue_.front();
96  return value_type(graph_.nodeData(e.first), graph_.edgeData(e.second));
97  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
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
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::firstChild ( )

Definition at line 110 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().

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  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
stack_type stack_
Definition: GraphWalker.h:58
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next ( void  )

Definition at line 142 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().

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  }
stack_type stack_
Definition: GraphWalker.h:58
result_type parent()
Definition: GraphWalker.h:132
result_type firstChild()
Definition: GraphWalker.h:110
result_type nextSibling()
Definition: GraphWalker.h:121
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::next_bfs ( )

Definition at line 160 of file GraphWalker.h.

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

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  }
const Graph< N, E > & graph_
Definition: GraphWalker.h:61
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
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::nextSibling ( )

Definition at line 121 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().

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  }
stack_type stack_
Definition: GraphWalker.h:58
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
template<class N , class E >
GraphWalker< N, E >::result_type math::GraphWalker< N, E >::parent ( )

Definition at line 132 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().

132  {
133  result_type result = false;
134  if (stack_.size() > 1) {
135  stack_.pop_back();
136  result = true;
137  }
138  return result;
139  }
stack_type stack_
Definition: GraphWalker.h:58
template<class N , class E >
void math::GraphWalker< N, E >::reset ( void  )

Definition at line 100 of file GraphWalker.h.

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

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_type stack_
Definition: GraphWalker.h:58
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: GraphWalker.h:22
edge_list root_
Definition: GraphWalker.h:60
template<class N, class E>
const stack_type& math::GraphWalker< N, E >::stack ( ) const
inline

Definition at line 54 of file GraphWalker.h.

Referenced by graph_combine(), and graph_tree_output().

54 { return stack_; }
stack_type stack_
Definition: GraphWalker.h:58

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