CMS 3D CMS Logo

Functions
GraphUtil.h File Reference
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"
#include <iostream>
#include <string>

Go to the source code of this file.

Functions

template<class N , class E >
void graph_combine (const math::Graph< N, E > &g1, const math::Graph< N, E > &g2, const N &n1, const N &n2, const N &root, math::Graph< N, E > &result)
 
template<class N , class E >
void graph_tree_output (const math::Graph< N, E > &g, const N &root, std::ostream &os)
 
template<class N , class E >
void output (const math::Graph< N, E > &g, const N &root)
 

Function Documentation

template<class N , class E >
void graph_combine ( const math::Graph< N, E > &  g1,
const math::Graph< N, E > &  g2,
const N n1,
const N n2,
const N root,
math::Graph< N, E > &  result 
)

Definition at line 22 of file GraphUtil.h.

References math::Graph< N, E >::addEdge(), math::GraphWalker< N, E >::current(), plotBeamSpotDB::first, diffTwoXMLs::g1, N, math::GraphWalker< N, E >::next(), math::Graph< N, E >::nodeData(), class-composition::parent, math::Graph< N, E >::replace(), and math::GraphWalker< N, E >::stack().

25 {
26  result = g1;
27  result.replace(n1,n2);
28  math::GraphWalker<N,E> walker(g2,n2);
29  while (walker.next()) {
30  const N & parent = g2.nodeData((++walker.stack().rbegin())->first->first);
31  result.addEdge(parent, walker.current().first, walker.current().second);
32  }
33  result.replace(n2,root);
34 }
void addEdge(const N &from, const N &to, const E &edge)
Definition: Graph.h:261
bool replace(const N &oldNode, const N &newNode)
Definition: Graph.h:356
const N & nodeData(const edge_type &) const
Definition: Graph.h:312
#define N
Definition: blowfish.cc:9
template<class N , class E >
void graph_tree_output ( const math::Graph< N, E > &  g,
const N root,
std::ostream &  os 
)

Definition at line 37 of file GraphUtil.h.

References math::GraphWalker< N, E >::current(), egammaForCoreTracking_cff::depth, math::GraphWalker< N, E >::firstChild(), math::GraphWalker< N, E >::nextSibling(), math::GraphWalker< N, E >::parent(), alignCSCRings::s, math::GraphWalker< N, E >::stack(), AlCaHLTBitMon_QueryRunRegistry::string, and w.

38 {
40  bool go=true;
41  unsigned int depth=0;
42  while (go) {
43  std::string s(2*depth,' ');
44  os << ' ' << s << w.current().first << '(' << w.current().second << ')' << std::endl;
45  go = w.firstChild();
46  if( go ) {
47  ++depth;
48  }
49  else if(w.stack().size() >1 && w.nextSibling()) {
50  go=true;
51  }
52  else {
53  go=false;
54  while(w.parent()) {
55  --depth;
56  if (w.stack().size()>1 && w.nextSibling()) {
57  go=true;
58  break;
59  }
60  }
61  }
62  }
63 }
const double w
Definition: UKUtility.cc:23
template<class N , class E >
void output ( const math::Graph< N, E > &  g,
const N root 
)

Definition at line 10 of file GraphUtil.h.

References gather_cfg::cout, math::GraphWalker< N, E >::current(), math::GraphWalker< N, E >::next(), and w.

11 {
13  bool go=true;
14  while(go) {
15  std::cout << w.current().first << ' ';
16  go=w.next();
17  }
18  std::cout << std::endl;
19 }
const double w
Definition: UKUtility.cc:23