CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TICLGraph Class Reference

#include <TICLGraph.h>

Public Member Functions

void dfsForCC (unsigned int nodeIndex, std::unordered_set< unsigned int > &visited, std::vector< unsigned int > &component) const
 
std::vector< std::vector< unsigned int > > findSubComponents ()
 
std::vector< std::vector< unsigned int > > getConnectedComponents () const
 
const ticl::NodegetNode (int i) const
 
const std::vector< ticl::Node > & getNodes () const
 
 TICLGraph ()=default
 
 TICLGraph (std::vector< ticl::Node > &n, std::vector< int > isRootNode)
 
 ~TICLGraph ()=default
 

Private Attributes

std::vector< int > isRootNode_
 
std::vector< ticl::Nodenodes_
 

Detailed Description

Definition at line 42 of file TICLGraph.h.

Constructor & Destructor Documentation

◆ TICLGraph() [1/2]

TICLGraph::TICLGraph ( )
default

◆ TICLGraph() [2/2]

TICLGraph::TICLGraph ( std::vector< ticl::Node > &  n,
std::vector< int >  isRootNode 
)
inline

Definition at line 47 of file TICLGraph.h.

References isRootNode_, dqmiodumpmetadata::n, and nodes_.

47  {
48  nodes_ = n;
49  isRootNode_ = isRootNode;
50  };
std::vector< int > isRootNode_
Definition: TICLGraph.h:66
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65

◆ ~TICLGraph()

TICLGraph::~TICLGraph ( )
default

Member Function Documentation

◆ dfsForCC()

void TICLGraph::dfsForCC ( unsigned int  nodeIndex,
std::unordered_set< unsigned int > &  visited,
std::vector< unsigned int > &  component 
) const

Definition at line 35 of file TICLGraph.cc.

References nodes_, and class-composition::visited.

Referenced by getConnectedComponents().

37  {
38  visited.insert(nodeIndex);
39  component.push_back(nodeIndex);
40 
41  for (auto const& neighbourIndex : nodes_[nodeIndex].getOuterNeighbours()) {
42  if (visited.find(neighbourIndex) == visited.end()) {
43  dfsForCC(neighbourIndex, visited, component);
44  }
45  }
46 }
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65
void dfsForCC(unsigned int nodeIndex, std::unordered_set< unsigned int > &visited, std::vector< unsigned int > &component) const
Definition: TICLGraph.cc:35

◆ findSubComponents()

std::vector< std::vector< unsigned int > > TICLGraph::findSubComponents ( )

Definition at line 20 of file TICLGraph.cc.

References makeMuonMisalignmentScenario::components, l1ctLayer2EG_cff::id, isRootNode_, nodes_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ticl::TracksterLinkingbySkeletons::linkTracksters().

20  {
21  std::vector<std::vector<unsigned int>> components;
22  for (auto const& node : nodes_) {
23  auto const id = node.getId();
24  if (isRootNode_[id]) {
25  //LogDebug("TICLGraph") << "DFS Starting From " << id << std::endl;
26  std::string tabs = "\t";
27  std::vector<unsigned int> tmpSubComponents;
28  nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs);
29  components.push_back(tmpSubComponents);
30  }
31  }
32  return components;
33 }
std::vector< int > isRootNode_
Definition: TICLGraph.h:66
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65

◆ getConnectedComponents()

std::vector< std::vector< unsigned int > > TICLGraph::getConnectedComponents ( ) const

Definition at line 48 of file TICLGraph.cc.

References makeMuonMisalignmentScenario::components, dfsForCC(), mps_fire::i, nodes_, and class-composition::visited.

48  {
49  std::unordered_set<unsigned int> visited;
50  std::vector<std::vector<unsigned int>> components;
51 
52  for (unsigned int i = 0; i < nodes_.size(); ++i) {
53  if (visited.find(i) == visited.end()) {
54  std::vector<unsigned int> component;
55  dfsForCC(i, visited, component);
56  components.push_back(component);
57  }
58  }
59  return components;
60 }
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65
void dfsForCC(unsigned int nodeIndex, std::unordered_set< unsigned int > &visited, std::vector< unsigned int > &component) const
Definition: TICLGraph.cc:35

◆ getNode()

const ticl::Node& TICLGraph::getNode ( int  i) const
inline

Definition at line 52 of file TICLGraph.h.

References mps_fire::i, and nodes_.

52 { return nodes_[i]; }
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65

◆ getNodes()

const std::vector<ticl::Node>& TICLGraph::getNodes ( void  ) const
inline

Definition at line 51 of file TICLGraph.h.

References nodes_.

51 { return nodes_; }
std::vector< ticl::Node > nodes_
Definition: TICLGraph.h:65

Member Data Documentation

◆ isRootNode_

std::vector<int> TICLGraph::isRootNode_
private

Definition at line 66 of file TICLGraph.h.

Referenced by findSubComponents(), and TICLGraph().

◆ nodes_

std::vector<ticl::Node> TICLGraph::nodes_
private