CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
graph_util.h File Reference
#include "DetectorDescription/Core/interface/adjgraph.h"
#include "DetectorDescription/Core/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 graph< N, E > &g1, const graph< N, E > &g2, const N &n1, const N &n2, const N &root, graph< N, E > &result)
 
template<class N , class E >
void graph_tree_output (const graph< N, E > &g, const N &root, std::ostream &os)
 
template<class N , class E >
void output (const graph< N, E > &g, const N &root)
 

Function Documentation

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

Definition at line 26 of file graph_util.h.

References graph< N, E >::addEdge(), graphwalker< N, E >::current(), first, graph< N, E >::value_type::first, diffTwoXMLs::g1, N, graphwalker< N, E >::next(), graph< N, E >::nodeData(), dbtoconf::parent, graph< N, E >::replace(), graph< N, E >::value_type::second, and graphwalker< N, E >::stack().

29 {
30  result = g1;
31  result.replace(n1,n2);
32  //output(result,n2);
33  graphwalker<N,E> walker(g2,n2);
34  while (walker.next()) {
35  const N & parent = g2.nodeData((++walker.stack().rbegin())->first->first);
36  /*
37  N parent = g2.nodeData((++walker.stack().rbegin())->first->first);
38  N child = walker.current().first;
39  E edge = walker.current().second;
40  */
41  //std::cout << parent << ' ' << walker.current().first << ' ' << walker.current().second<< std::endl;
42  result.addEdge(parent, walker.current().first, walker.current().second);
43  //result.addEdge(parent,child,edge);
44  //result.dump_graph();
45  //output(result,n2);
46  }
47  result.replace(n2,root);
48  //output(result,root);
49 }
list parent
Definition: dbtoconf.py:74
const N & nodeData(const edge_type &) const
Definition: adjgraph.h:317
bool first
Definition: L1TdeRCT.cc:94
#define N
Definition: blowfish.cc:9
bool replace(const N &oldNode, const N &newNode)
Definition: adjgraph.h:367
void addEdge(const N &from, const N &to, const E &edge)
Definition: adjgraph.h:266
string root
initialization
Definition: dbtoconf.py:70
template<class N , class E >
void graph_tree_output ( const graph< N, E > &  g,
const N root,
std::ostream &  os 
)

Definition at line 53 of file graph_util.h.

References graphwalker< N, E >::current(), graph< N, E >::value_type::first, graphwalker< N, E >::firstChild(), graphwalker< N, E >::nextSibling(), graphwalker< N, E >::parent(), alignCSCRings::s, graph< N, E >::value_type::second, graphwalker< N, E >::stack(), AlCaHLTBitMon_QueryRunRegistry::string, and w().

54 {
56  bool go=true;
57  unsigned int depth=0;
58  while (go) {
59  std::string s(2*depth,' ');
60  os << ' ' << s << w.current().first << '(' << w.current().second << ')' << std::endl;
61  if (go=w.firstChild()) {
62  ++depth;
63  }
64  else if(w.stack().size() >1 && w.nextSibling()) {
65  go=true;
66  }
67  else {
68  go=false;
69  while(w.parent()) {
70  --depth;
71  if (w.stack().size()>1 && w.nextSibling()) {
72  go=true;
73  break;
74  }
75  }
76  }
77 
78  }
79 }
T w() const
string root
initialization
Definition: dbtoconf.py:70
template<class N , class E >
void output ( const graph< N, E > &  g,
const N root 
)

Definition at line 14 of file graph_util.h.

References gather_cfg::cout, graphwalker< N, E >::current(), graph< N, E >::value_type::first, graphwalker< N, E >::next(), and w().

15 {
17  bool go=true;
18  while(go) {
19  std::cout << w.current().first << ' ';
20  go=w.next();
21  }
22  std::cout << std::endl;
23 }
tuple cout
Definition: gather_cfg.py:121
T w() const
string root
initialization
Definition: dbtoconf.py:70