CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 21 of file GraphUtil.h.

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

26  {
27  result = g1;
28  result.replace(n1, n2);
29  math::GraphWalker<N, E> walker(g2, n2);
30  while (walker.next()) {
31  const N& parent = g2.nodeData((++walker.stack().rbegin())->first->first);
32  result.addEdge(parent, walker.current().first, walker.current().second);
33  }
34  result.replace(n2, root);
35 }
void addEdge(const N &from, const N &to, const E &edge)
Definition: Graph.h:231
bool replace(const N &oldNode, const N &newNode)
Definition: Graph.h:310
const N & nodeData(const edge_type &) const
Definition: Graph.h:272
#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 38 of file GraphUtil.h.

References math::GraphWalker< N, E >::current(), HLT_FULL_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  {
39  math::GraphWalker<N, E> w(g, root);
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  } else if (w.stack().size() > 1 && w.nextSibling()) {
49  go = true;
50  } else {
51  go = false;
52  while (w.parent()) {
53  --depth;
54  if (w.stack().size() > 1 && w.nextSibling()) {
55  go = true;
56  break;
57  }
58  }
59  }
60  }
61 }
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.

10  {
11  math::GraphWalker<N, E> w(g, root);
12  bool go = true;
13  while (go) {
14  std::cout << w.current().first << ' ';
15  go = w.next();
16  }
17  std::cout << std::endl;
18 }
const double w
Definition: UKUtility.cc:23
tuple cout
Definition: gather_cfg.py:144