test
CMS 3D CMS Logo

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

#include <adjgraph.h>

Classes

class  const_iterator
 
struct  value_type
 

Public Types

typedef adj_list::iterator adj_iterator
 
typedef std::vector< edge_listadj_list
 
typedef adj_list::const_iterator const_adj_iterator
 
typedef edge_list::const_iterator const_edge_iterator
 
typedef std::pair
< const_edge_iterator,
const_edge_iterator
const_edge_range
 
typedef
indexer_type::const_iterator 
const_indexer_iterator
 
typedef edge_list::iterator edge_iterator
 
typedef std::vector< edge_typeedge_list
 
typedef std::pair
< edge_iterator, edge_iterator
edge_range
 
typedef std::vector< E > edge_store
 
typedef std::pair< index_type,
index_type
edge_type
 
typedef std::pair< index_type,
bool > 
index_result
 
typedef std::vector< double >
::size_type 
index_type
 
typedef indexer_type::iterator indexer_iterator
 
typedef std::map< N, index_typeindexer_type
 
typedef std::vector< Nnode_list
 

Public Member Functions

void addEdge (const N &from, const N &to, const E &edge)
 
index_type addNode (const N &)
 
adj_iterator begin ()
 
const_adj_iterator begin () const
 
const_iterator begin_iter () const
 
void clear ()
 it clear everything! More...
 
void dump_graph (void) const
 
size_t edge_size () const
 
const E & edgeData (index_type i) const
 
edge_range edges (index_type nodeIndex)
 
const_edge_range edges (index_type nodeIndex) const
 
edge_range edges (const N &)
 
const_edge_range edges (const N &) const
 
adj_iterator end ()
 
const_adj_iterator end () const
 
const_iterator end_iter () const
 
void findRoots (edge_list &) const
 
 graph ()
 
void invert (graph &g) const
 
const NnodeData (const edge_type &) const
 
const NnodeData (index_type) const
 
const NnodeData (const const_adj_iterator &) const
 
index_result nodeIndex (const N &) const
 
bool replace (const N &oldNode, const N &newNode)
 
bool replaceEdge (const E &ldEdge, const E &newEdge)
 
adj_list::size_type size () const
 
void swap (graph< N, E > &)
 
 ~graph ()
 

Private Attributes

adj_list adjl_
 
edge_store edges_
 
edge_list emptyEdges_
 
indexer_type indexer_
 
node_list nodes_
 

Detailed Description

template<class N, class E>
class graph< N, E >

Definition at line 12 of file adjgraph.h.

Member Typedef Documentation

template<class N, class E>
typedef adj_list::iterator graph< N, E >::adj_iterator

Definition at line 124 of file adjgraph.h.

template<class N, class E>
typedef std::vector<edge_list> graph< N, E >::adj_list

Definition at line 21 of file adjgraph.h.

template<class N, class E>
typedef adj_list::const_iterator graph< N, E >::const_adj_iterator

Definition at line 125 of file adjgraph.h.

template<class N, class E>
typedef edge_list::const_iterator graph< N, E >::const_edge_iterator

Definition at line 136 of file adjgraph.h.

template<class N, class E>
typedef std::pair<const_edge_iterator, const_edge_iterator> graph< N, E >::const_edge_range

Definition at line 140 of file adjgraph.h.

template<class N, class E>
typedef indexer_type::const_iterator graph< N, E >::const_indexer_iterator

Definition at line 131 of file adjgraph.h.

template<class N, class E>
typedef edge_list::iterator graph< N, E >::edge_iterator

Definition at line 134 of file adjgraph.h.

template<class N, class E>
typedef std::vector<edge_type> graph< N, E >::edge_list

Definition at line 19 of file adjgraph.h.

template<class N, class E>
typedef std::pair<edge_iterator,edge_iterator> graph< N, E >::edge_range

Definition at line 138 of file adjgraph.h.

template<class N, class E>
typedef std::vector<E> graph< N, E >::edge_store

Definition at line 121 of file adjgraph.h.

template<class N, class E>
typedef std::pair<index_type, index_type> graph< N, E >::edge_type

Definition at line 17 of file adjgraph.h.

template<class N, class E>
typedef std::pair<index_type, bool> graph< N, E >::index_result

Definition at line 142 of file adjgraph.h.

template<class N, class E>
typedef std::vector<double>::size_type graph< N, E >::index_type

Definition at line 15 of file adjgraph.h.

template<class N, class E>
typedef indexer_type::iterator graph< N, E >::indexer_iterator

Definition at line 130 of file adjgraph.h.

template<class N, class E>
typedef std::map<N, index_type> graph< N, E >::indexer_type

Definition at line 129 of file adjgraph.h.

template<class N, class E>
typedef std::vector<N> graph< N, E >::node_list

Definition at line 120 of file adjgraph.h.

Constructor & Destructor Documentation

template<class N, class E>
graph< N, E >::graph ( )
inline

Definition at line 146 of file adjgraph.h.

Referenced by cuy.FindIssue::__init__().

146 : edges_(1) { }
edge_store edges_
Definition: adjgraph.h:221
template<class N, class E>
graph< N, E >::~graph ( )
inline

Definition at line 147 of file adjgraph.h.

147 { }

Member Function Documentation

template<class N, class E>
void graph< N, E >::addEdge ( const N from,
const N to,
const E &  edge 
)

Definition at line 266 of file adjgraph.h.

Referenced by graph_combine(), graph< N, E >::invert(), and DDCompactViewImpl::position().

267 {
268  index_type iFrom = addNode(from);
269  index_type iTo = addNode(to);
270 
271  adjl_[iFrom].push_back(edge_type(iTo,edges_.size()));
272  edges_.push_back(edge);
273 }
adj_list adjl_
Definition: adjgraph.h:215
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
std::pair< index_type, index_type > edge_type
Definition: adjgraph.h:17
edge_store edges_
Definition: adjgraph.h:221
index_type addNode(const N &)
Definition: adjgraph.h:234
template<class N, class E >
graph< N, E >::index_type graph< N, E >::addNode ( const N node)

Definition at line 234 of file adjgraph.h.

References customizeTrackingMonitorSeedNumber::idx, and mps_fire::result.

235 {
236  index_type idx = indexer_.size() ; // +1;
237  std::pair<indexer_iterator,bool> result
238  = indexer_.insert(typename indexer_type::value_type(node,idx));
239 
240  if ( result.second ) { // new index!
241  nodes_.push_back(node);
242  adjl_.push_back(edge_list());
243  }
244  else {
245  idx = result.first->second;
246  }
247  return idx;
248 }
adj_list adjl_
Definition: adjgraph.h:215
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
tuple result
Definition: mps_fire.py:84
std::vector< edge_type > edge_list
Definition: adjgraph.h:19
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
node_list nodes_
Definition: adjgraph.h:218
indexer_type indexer_
Definition: adjgraph.h:224
template<class N, class E>
adj_iterator graph< N, E >::begin ( void  )
inline
template<class N, class E>
const_adj_iterator graph< N, E >::begin ( void  ) const
inline

Definition at line 198 of file adjgraph.h.

198 { return adjl_.begin(); }
adj_list adjl_
Definition: adjgraph.h:215
template<class N, class E>
const_iterator graph< N, E >::begin_iter ( ) const
inline

Definition at line 190 of file adjgraph.h.

Referenced by DDStreamer::pos_write().

190 { return const_iterator(*this); }
template<class N , class E >
void graph< N, E >::clear ( void  )
template<class N , class E >
void graph< N, E >::dump_graph ( void  ) const

Definition at line 410 of file adjgraph.h.

411 {
412  // std::cout << adjl_ << std::endl;
413  /*
414  std::cout << "Nodes and their indices:" << std::endl;
415  typename indexer_type::const_iterator it = indexer_.begin();
416  for (; it != indexer_.end(); ++it) {
417  std::cout << ' ' << it->first << ' ' << it->second << std::endl;
418  }
419  */
420 }
template<class N, class E>
size_t graph< N, E >::edge_size ( ) const
inline

Definition at line 194 of file adjgraph.h.

194 { return edges_.size(); }
edge_store edges_
Definition: adjgraph.h:221
template<class N, class E>
const E& graph< N, E >::edgeData ( index_type  i) const
inline
template<class N , class E >
graph< N, E >::edge_range graph< N, E >::edges ( index_type  nodeIndex)
inline

Definition at line 277 of file adjgraph.h.

Referenced by DDCheckAll(), DDErrorDetection::lp_cpv(), and DDCompactViewImpl::~DDCompactViewImpl().

278 {
280  return edge_range(edges.begin(), edges.end());
281 }
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:138
adj_list adjl_
Definition: adjgraph.h:215
std::vector< edge_type > edge_list
Definition: adjgraph.h:19
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
index_result nodeIndex(const N &) const
Definition: adjgraph.h:252
template<class N , class E >
graph< N, E >::const_edge_range graph< N, E >::edges ( index_type  nodeIndex) const
inline

Definition at line 285 of file adjgraph.h.

286 {
287  const edge_list & edges = adjl_[nodeIndex];
288  return const_edge_range(edges.begin(), edges.end());
289 }
std::pair< const_edge_iterator, const_edge_iterator > const_edge_range
Definition: adjgraph.h:140
adj_list adjl_
Definition: adjgraph.h:215
std::vector< edge_type > edge_list
Definition: adjgraph.h:19
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
index_result nodeIndex(const N &) const
Definition: adjgraph.h:252
template<class N, class E >
graph< N, E >::edge_range graph< N, E >::edges ( const N node)
inline

Definition at line 293 of file adjgraph.h.

References mps_fire::result.

294 {
295  index_result idxResult = nodeIndex(node);
296  edge_range result(emptyEdges_.begin(),emptyEdges_.end());
297  if (idxResult.second) {
298  result = edges(idxResult.first);
299  }
300  return result;
301 }
std::pair< index_type, bool > index_result
Definition: adjgraph.h:142
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:138
edge_list emptyEdges_
Definition: adjgraph.h:227
tuple result
Definition: mps_fire.py:84
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
index_result nodeIndex(const N &) const
Definition: adjgraph.h:252
template<class N, class E >
graph< N, E >::const_edge_range graph< N, E >::edges ( const N node) const
inline

Definition at line 305 of file adjgraph.h.

References mps_fire::result.

306 {
307  index_result idxResult = nodeIndex(node);
309  if (idxResult.second) {
310  result = edges(idxResult.first);
311  }
312  return result;
313 }
std::pair< index_type, bool > index_result
Definition: adjgraph.h:142
std::pair< const_edge_iterator, const_edge_iterator > const_edge_range
Definition: adjgraph.h:140
edge_list emptyEdges_
Definition: adjgraph.h:227
tuple result
Definition: mps_fire.py:84
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
index_result nodeIndex(const N &) const
Definition: adjgraph.h:252
template<class N, class E>
adj_iterator graph< N, E >::end ( void  )
inline
template<class N, class E>
const_adj_iterator graph< N, E >::end ( void  ) const
inline

Definition at line 200 of file adjgraph.h.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

200 { return adjl_.end(); }
adj_list adjl_
Definition: adjgraph.h:215
template<class N, class E>
const_iterator graph< N, E >::end_iter ( ) const
inline

Definition at line 192 of file adjgraph.h.

Referenced by DDStreamer::pos_write().

192 { return const_iterator(*this, adjl_.size(),0); }
adj_list adjl_
Definition: adjgraph.h:215
template<class N , class E >
void graph< N, E >::findRoots ( edge_list result) const

Definition at line 337 of file adjgraph.h.

References begin, end, and findQualityFiles::size.

338 {
339  result.clear();
340 
341  const_adj_iterator it = begin();
342  const_adj_iterator ed = end();
343  std::vector<bool> rootCandidate(size(), true);
344 
345  for (; it != ed; ++it) {
346  const edge_list & el = *it;
347  typename edge_list::const_iterator el_it = el.begin();
348  typename edge_list::const_iterator el_ed = el.end();
349  for (; el_it != el_ed; ++el_it) {
350  rootCandidate[el_it->first]=false;
351  //el_rt = el_it; // stop at the first encountered candidate!
352  //std::cout << "graphwalker: found a root candidate = " << g.nodeData(el_rt->first) << std::endl;
353  //break;
354  }
355  }
357  std::vector<bool>::size_type v_ed = rootCandidate.size();
358  for (; v_sz < v_ed; ++v_sz) {
359  if (rootCandidate[v_sz]) {
360  //std::cout << "found = " << g.nodeData(v_sz) << std::endl;
361  result.push_back(edge_type(v_sz,0));
362  }
363  }
364 }
adj_list::size_type size() const
Definition: adjgraph.h:201
uint16_t size_type
std::pair< index_type, index_type > edge_type
Definition: adjgraph.h:17
tuple result
Definition: mps_fire.py:84
std::vector< edge_type > edge_list
Definition: adjgraph.h:19
adj_list::const_iterator const_adj_iterator
Definition: adjgraph.h:125
adj_iterator begin()
Definition: adjgraph.h:197
adj_iterator end()
Definition: adjgraph.h:199
template<class N , class E >
void graph< N, E >::invert ( graph< N, E > &  g) const

Definition at line 424 of file adjgraph.h.

References graph< N, E >::addEdge(), and alignCSCRings::e.

425 {
426  adj_list::size_type it = 0;
427  adj_list::size_type ed = adjl_.size();
428  // loop over adjacency-list of this graph
429  for (; it < ed; ++it) {
430  const edge_list & el = adjl_[it];
431  edge_list::size_type eit = 0;
432  edge_list::size_type eed = el.size();
433  // loop over edges of current node
434  for (; eit < eed; ++eit) {
435  const edge_type & e = el[eit];
436  g.addEdge(nodeData(e.first), nodeData(it), edgeData(e.second));
437  }
438  }
439 }
adj_list adjl_
Definition: adjgraph.h:215
const N & nodeData(const edge_type &) const
Definition: adjgraph.h:317
const E & edgeData(index_type i) const
Definition: adjgraph.h:183
uint16_t size_type
std::pair< index_type, index_type > edge_type
Definition: adjgraph.h:17
std::vector< edge_type > edge_list
Definition: adjgraph.h:19
void addEdge(const N &from, const N &to, const E &edge)
Definition: adjgraph.h:266
template<class N , class E >
const N & graph< N, E >::nodeData ( const edge_type edge) const
inline
template<class N , class E >
const N & graph< N, E >::nodeData ( index_type  i) const
inline

Definition at line 324 of file adjgraph.h.

References i.

325 {
326  return nodes_[i];
327 }
int i
Definition: DBlmapReader.cc:9
node_list nodes_
Definition: adjgraph.h:218
template<class N , class E >
const N & graph< N, E >::nodeData ( const const_adj_iterator it) const
inline

Definition at line 331 of file adjgraph.h.

332 {
333  return nodes_[it-adjl_.begin()];
334 }
adj_list adjl_
Definition: adjgraph.h:215
node_list nodes_
Definition: adjgraph.h:218
template<class N, class E >
graph< N, E >::index_result graph< N, E >::nodeIndex ( const N node) const
inline

Definition at line 252 of file adjgraph.h.

References customizeTrackingMonitorSeedNumber::idx, and mps_fire::result.

Referenced by DDErrorDetection::lp_cpv().

253 {
254  typename indexer_type::const_iterator result = indexer_.find(node);
255  index_type idx = 0;
256  bool flag = false;
257  if (result != indexer_.end()) {
258  flag = true;
259  idx = result->second;
260  }
261  return index_result(idx, flag);
262 }
std::pair< index_type, bool > index_result
Definition: adjgraph.h:142
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
tuple result
Definition: mps_fire.py:84
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
indexer_type indexer_
Definition: adjgraph.h:224
template<class N, class E >
bool graph< N, E >::replace ( const N oldNode,
const N newNode 
)

Definition at line 367 of file adjgraph.h.

Referenced by graph_combine().

368 {
369  typename indexer_type::iterator it = indexer_.find(oldNode);
370  if (it != indexer_.end()) {
371  index_type oldIndex = it->second;
372  nodes_[oldIndex]=newNode;
373  indexer_[newNode]=oldIndex;
374  indexer_.erase(it);
375  }
376  else throw(oldNode);
377  return true;
378 }
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
node_list nodes_
Definition: adjgraph.h:218
indexer_type indexer_
Definition: adjgraph.h:224
template<class N , class E>
bool graph< N, E >::replaceEdge ( const E &  ldEdge,
const E &  newEdge 
)

Definition at line 381 of file adjgraph.h.

References mps_fire::result.

382 {
383  typename edge_store::size_type it = 0;
384  typename edge_store::size_type ed = edges_.size();
385  bool result = false;
386  //std::cout << "newedge=" << newEdge << std::endl;
387  for (; it < ed; ++it) {
388  //std::cout << "edge=" << edges_[it] << " ";
389  if ( edges_[it] == oldEdge ) {
390  //std::cout << "FOUND!" << std::endl;
391  result = true;
392  edges_[it] = newEdge;
393  break;
394  }
395  }
396  //std::cout << std::endl;
397  return result;
398 }
uint16_t size_type
tuple result
Definition: mps_fire.py:84
edge_store edges_
Definition: adjgraph.h:221
template<class N, class E>
adj_list::size_type graph< N, E >::size ( void  ) const
inline
template<class N, class E>
void graph< N, E >::swap ( graph< N, E > &  g)

Definition at line 442 of file adjgraph.h.

References graph< N, E >::adjl_, graph< N, E >::edges_, graph< N, E >::emptyEdges_, graph< N, E >::indexer_, and graph< N, E >::nodes_.

Referenced by DDCompactViewImpl::swap().

442  {
443  adjl_.swap(g.adjl_);
444  nodes_.swap(g.nodes_);
445  edges_.swap(g.edges_);
446  indexer_.swap(g.indexer_);
447  emptyEdges_.swap(g.emptyEdges_);
448 }
adj_list adjl_
Definition: adjgraph.h:215
edge_list emptyEdges_
Definition: adjgraph.h:227
edge_store edges_
Definition: adjgraph.h:221
node_list nodes_
Definition: adjgraph.h:218
indexer_type indexer_
Definition: adjgraph.h:224

Member Data Documentation

template<class N, class E>
adj_list graph< N, E >::adjl_
private
template<class N, class E>
edge_store graph< N, E >::edges_
private
template<class N, class E>
edge_list graph< N, E >::emptyEdges_
private

Definition at line 227 of file adjgraph.h.

Referenced by graph< N, E >::swap().

template<class N, class E>
indexer_type graph< N, E >::indexer_
private

Definition at line 224 of file adjgraph.h.

Referenced by graph< N, E >::swap().

template<class N, class E>
node_list graph< N, E >::nodes_
private

Definition at line 218 of file adjgraph.h.

Referenced by graph< N, E >::swap().