CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Attributes | Private Member Functions
graphwalker< N, E > Class Template Reference

#include <graphwalker.h>

Public Types

typedef std::queue< edge_typebfs_type
 
typedef graph< N, E >
::const_edge_iterator 
const_edge_iterator
 
typedef graph< N, E >
::edge_iterator 
edge_iterator
 
typedef graph< N, E >::edge_list edge_list
 
typedef std::pair
< const_edge_iterator,
const_edge_iterator
edge_range
 
typedef graph< N, E >::edge_type edge_type
 
typedef graph< N, E >::index_result index_result
 
typedef graph< N, E >::index_type index_type
 
typedef bool result_type
 
typedef std::vector< edge_rangestack_type
 
typedef graph< N, E >::value_type 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 ()
 

Detailed Description

template<class N, class E>
class graphwalker< N, E >

a walker for an acyclic directed multigraph

Definition at line 13 of file graphwalker.h.

Member Typedef Documentation

template<class N, class E>
typedef std::queue<edge_type> graphwalker< N, E >::bfs_type

Definition at line 34 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::const_edge_iterator graphwalker< N, E >::const_edge_iterator

Definition at line 26 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::edge_iterator graphwalker< N, E >::edge_iterator

Definition at line 24 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::edge_list graphwalker< N, E >::edge_list

Definition at line 22 of file graphwalker.h.

template<class N, class E>
typedef std::pair<const_edge_iterator, const_edge_iterator> graphwalker< N, E >::edge_range

Definition at line 29 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::edge_type graphwalker< N, E >::edge_type

Definition at line 20 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::index_result graphwalker< N, E >::index_result

Definition at line 18 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::index_type graphwalker< N, E >::index_type

Definition at line 16 of file graphwalker.h.

template<class N, class E>
typedef bool graphwalker< N, E >::result_type

Definition at line 36 of file graphwalker.h.

template<class N, class E>
typedef std::vector<edge_range> graphwalker< N, E >::stack_type

Definition at line 33 of file graphwalker.h.

template<class N, class E>
typedef graph<N,E>::value_type graphwalker< N, E >::value_type

Definition at line 38 of file graphwalker.h.

Constructor & Destructor Documentation

template<class N, class E>
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 83 of file graphwalker.h.

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

84  : graph_(g)
85 { // complexity = (no nodes) * (no edges)
86  graph_.findRoots(root_);
87  stack_.push_back(edge_range(root_.begin(),root_.end()));
88  if (root_.size()) {
89  queue_.push(root_[0]);
90  }
91 }
stack_type stack_
Definition: graphwalker.h:69
const graph< N, E > & graph_
Definition: graphwalker.h:73
bfs_type queue_
Definition: graphwalker.h:70
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
edge_list root_
Definition: graphwalker.h:71
template<class N, class E>
graphwalker< N, E >::graphwalker ( const graph< N, E > &  g,
const N root 
)

creates a walker rooted by the node given

Definition at line 95 of file graphwalker.h.

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

96  : graph_(g)
97 {
98  index_result rr = graph_.nodeIndex(root);
99  if (!rr.second) // no such root node, no walker can be created!
100  throw root;
101 
102  root_.push_back(edge_type(rr.first, 0));
103  stack_.push_back(edge_range(root_.begin(),root_.end()));
104  queue_.push(root_[0]);
105 }
stack_type stack_
Definition: graphwalker.h:69
const graph< N, E > & graph_
Definition: graphwalker.h:73
bfs_type queue_
Definition: graphwalker.h:70
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
graph< N, E >::edge_type edge_type
Definition: graphwalker.h:20
graph< N, E >::index_result index_result
Definition: graphwalker.h:18
edge_list root_
Definition: graphwalker.h:71
template<class N, class E>
graphwalker< N, E >::graphwalker ( )
private

Member Function Documentation

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

Definition at line 109 of file graphwalker.h.

Referenced by DDCheckConnect(), graph_combine(), graph_tree_output(), output(), and DDCompactViewImpl::weight().

110 {
111  const edge_range & er = stack_.back();
112 /*
113  const N & n = graph_.nodeData(er.first->first);
114  const E & e = er.first->first;
115  return value_type(n,e);
116 */
117  return value_type(graph_.nodeData(er.first->first), graph_.edgeData(er.first->second));
118 }
stack_type stack_
Definition: graphwalker.h:69
const graph< N, E > & graph_
Definition: graphwalker.h:73
graph< N, E >::value_type value_type
Definition: graphwalker.h:38
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
template<class N , class E >
graphwalker< N, E >::value_type graphwalker< N, E >::current_bfs ( ) const

Definition at line 122 of file graphwalker.h.

References alignCSCRings::e.

123 {
124  const edge_type & e = queue_.front();
125  return value_type(graph_.nodeData(e.first), graph_.edgeData(e.second));
126 }
const graph< N, E > & graph_
Definition: graphwalker.h:73
bfs_type queue_
Definition: graphwalker.h:70
graph< N, E >::value_type value_type
Definition: graphwalker.h:38
graph< N, E >::edge_type edge_type
Definition: graphwalker.h:20
template<class N , class E >
graphwalker< N, E >::result_type graphwalker< N, E >::firstChild ( )

Definition at line 143 of file graphwalker.h.

References mps_fire::result.

Referenced by graph_tree_output(), and DDCompactViewImpl::weight().

144 {
145  result_type result = false;
146  const edge_range & adjEdges
147  = graph_.edges(stack_.back().first->first);
148  if (adjEdges.first != adjEdges.second) {
149  stack_.push_back(adjEdges);
150  result = true;
151  }
152  return result;
153 }
stack_type stack_
Definition: graphwalker.h:69
const graph< N, E > & graph_
Definition: graphwalker.h:73
bool result_type
Definition: graphwalker.h:36
tuple result
Definition: mps_fire.py:83
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
template<class N , class E >
graphwalker< N, E >::result_type graphwalker< N, E >::next ( void  )

Definition at line 185 of file graphwalker.h.

References mps_fire::result.

Referenced by BeautifulSoup.PageElement::_invert(), DDCheckConnect(), graph_combine(), and output().

186 {
187  result_type result = false;
188  if (firstChild()) {
189  result = true;
190  }
191  else if(stack_.size()>1 && nextSibling()) {
192  result = true;
193  }
194  else {
195  while(parent()) {
196  if(stack_.size()>1 && nextSibling()) {
197  result = true;
198  break;
199  }
200  }
201  }
202  return result;
203 }
stack_type stack_
Definition: graphwalker.h:69
result_type parent()
Definition: graphwalker.h:172
bool result_type
Definition: graphwalker.h:36
tuple result
Definition: mps_fire.py:83
result_type nextSibling()
Definition: graphwalker.h:157
result_type firstChild()
Definition: graphwalker.h:143
template<class N , class E >
graphwalker< N, E >::result_type graphwalker< N, E >::next_bfs ( )

Definition at line 206 of file graphwalker.h.

References alignCSCRings::e, and mps_fire::result.

207 {
208  result_type result(false);
209  if (!queue_.empty()) {
210  const edge_type & e = queue_.front();
211  const edge_range & er = graph_.edges(e.first);
212  const_edge_iterator it(er.first), ed(er.second);
213  for (; it != ed; ++it) {
214  queue_.push(*it);
215  }
216  queue_.pop();
217  if (!queue_.empty()) {
218  result=true;
219  }
220  }
221  return result;
222 }
const graph< N, E > & graph_
Definition: graphwalker.h:73
bool result_type
Definition: graphwalker.h:36
graph< N, E >::const_edge_iterator const_edge_iterator
Definition: graphwalker.h:26
tuple result
Definition: mps_fire.py:83
bfs_type queue_
Definition: graphwalker.h:70
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
graph< N, E >::edge_type edge_type
Definition: graphwalker.h:20
template<class N , class E >
graphwalker< N, E >::result_type graphwalker< N, E >::nextSibling ( )

Definition at line 157 of file graphwalker.h.

References mps_fire::result.

Referenced by BeautifulSoup.Tag::__str__(), BeautifulSoup.PageElement::_invert(), graph_tree_output(), and DDCompactViewImpl::weight().

158 {
159  result_type result = false;
160  //if (stack_.size() > 1) { only if single-root should be enforced ...
161  edge_range & siblings = stack_.back();
162  if (siblings.first != (siblings.second - 1) ) {
163  ++siblings.first;
164  result = true;
165  }
166  //}
167  return result;
168 }
stack_type stack_
Definition: graphwalker.h:69
bool result_type
Definition: graphwalker.h:36
tuple result
Definition: mps_fire.py:83
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
template<class N , class E >
graphwalker< N, E >::result_type graphwalker< N, E >::parent ( )

Definition at line 172 of file graphwalker.h.

References mps_fire::result.

Referenced by BeautifulSoup.PageElement::_invert(), 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(), 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().

173 {
174  //std::cout << "graphwalker::parent()" << std::endl;
175  result_type result = false;
176  if (stack_.size()>1) {
177  stack_.pop_back();
178  result = true;
179  }
180  return result;
181 }
stack_type stack_
Definition: graphwalker.h:69
bool result_type
Definition: graphwalker.h:36
tuple result
Definition: mps_fire.py:83
template<class N , class E >
void graphwalker< N, E >::reset ( void  )

Definition at line 130 of file graphwalker.h.

References sistrip::root_.

131 {
132  //std::cout << "graphwalker::reset" << std::endl;
133  stack_.clear();
134  stack_.push_back(edge_range(root_.begin(),root_.end()));
135  queue_.clear();
136  if (root_.size()) {
137  queue_.push(root_[0]);
138  }
139 }
stack_type stack_
Definition: graphwalker.h:69
bfs_type queue_
Definition: graphwalker.h:70
std::pair< const_edge_iterator, const_edge_iterator > edge_range
Definition: graphwalker.h:29
edge_list root_
Definition: graphwalker.h:71
template<class N, class E>
const stack_type& graphwalker< N, E >::stack ( ) const
inline

Definition at line 65 of file graphwalker.h.

Referenced by graph_combine(), and graph_tree_output().

65 { return stack_;}
stack_type stack_
Definition: graphwalker.h:69

Member Data Documentation

template<class N, class E>
const graph<N,E>& graphwalker< N, E >::graph_
protected

Definition at line 73 of file graphwalker.h.

Referenced by graphwalker< N, E >::graphwalker().

template<class N, class E>
bfs_type graphwalker< N, E >::queue_
protected

Definition at line 70 of file graphwalker.h.

Referenced by graphwalker< N, E >::graphwalker().

template<class N, class E>
edge_list graphwalker< N, E >::root_
protected

Definition at line 71 of file graphwalker.h.

Referenced by graphwalker< N, E >::graphwalker().

template<class N, class E>
stack_type graphwalker< N, E >::stack_
protected