CMS 3D CMS Logo

Functions

/data/refman/pasoursint/CMSSW_5_2_9/src/DetectorDescription/Core/interface/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, diffTwoXMLs::g1, N, graphwalker< N, E >::next(), graph< N, E >::nodeData(), dbtoconf::parent, graph< N, E >::replace(), and graphwalker< N, E >::stack().

{
  result = g1;
  result.replace(n1,n2);
  //output(result,n2);
  graphwalker<N,E> walker(g2,n2);
  while (walker.next()) {
    const N & parent = g2.nodeData((++walker.stack().rbegin())->first->first);
    /*
    N parent = g2.nodeData((++walker.stack().rbegin())->first->first);
    N child  = walker.current().first;
    E edge   = walker.current().second;
    */
    //std::cout << parent << ' ' << walker.current().first << ' ' << walker.current().second<< std::endl;
    result.addEdge(parent, walker.current().first, walker.current().second);
    //result.addEdge(parent,child,edge);
    //result.dump_graph();
    //output(result,n2);
  }
  result.replace(n2,root);                      
  //output(result,root);
}               
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(), graphwalker< N, E >::firstChild(), graphwalker< N, E >::nextSibling(), graphwalker< N, E >::parent(), alignCSCRings::s, graphwalker< N, E >::stack(), and w().

{
   graphwalker<N,E> w(g,root);
   bool go=true;
   unsigned int depth=0;
   while (go) {
     std::string s(2*depth,' ');
     os << ' ' << s << w.current().first << '(' << w.current().second << ')' << std::endl;
     if (go=w.firstChild()) {
       ++depth;
     }
     else if(w.stack().size() >1 && w.nextSibling()) {
        go=true;
     }
     else {
       go=false;
       while(w.parent()) {
         --depth;
          if (w.stack().size()>1 && w.nextSibling()) {
             go=true;
             break;
          }
       }
     }
     
   }  
}
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(), graphwalker< N, E >::next(), and w().

{
  graphwalker<N,E> w(g,root);
  bool go=true;
  while(go) {
    std::cout << w.current().first << ' ';
    go=w.next();
  }
  std::cout << std::endl;
}