Belle II Software  release-08-01-10
NodeFamilyDefiner< ContainerType, NodeType, NeighbourContainerType > Class Template Reference

This class assigns a common family identifier to all CACells in the network that are connected. More...

#include <NodeFamilyDefiner.h>

Public Member Functions

short defineFamilies (ContainerType &aNetwork)
 Assign a common family identifier to all Nodes in the network that are connected. More...
 

Private Member Functions

NeighbourContainerType markNodes (short family, const NeighbourContainerType &neighbours)
 Assign family to all connected nodes and return their neighbours.
 

Detailed Description

template<class ContainerType, class NodeType, class NeighbourContainerType>
class Belle2::NodeFamilyDefiner< ContainerType, NodeType, NeighbourContainerType >

This class assigns a common family identifier to all CACells in the network that are connected.

Requirements for ContainerType:

  • must have begin() and end() with iterator pointing to pointers of entries ( = ContainerType< NodeType*>)

Requirements for NodeType:

  • must have function: bool NodeType::setFamily()
  • must have function: bool NodeType::getFamily()
  • must have function: NeighbourContainerType& NodeType::getInnerNodes()
  • must have function: NeighbourContainerType& NodeType::getOuterNodes()

Requirements for NeighbourContainerType:

  • must have function: unsigned int (or comparable) NeighbourContainerType::size()
  • must support range based for loop

Definition at line 34 of file NodeFamilyDefiner.h.

Member Function Documentation

◆ defineFamilies()

short defineFamilies ( ContainerType &  aNetwork)
inline

Assign a common family identifier to all Nodes in the network that are connected.

Performs a width first flood fill algorithm. Returns total number of defined families.

Definition at line 42 of file NodeFamilyDefiner.h.

43  {
44  short currentFamily = 0;
45  for (NodeType* aNode : aNetwork) {
46  if (aNode->getFamily() != -1) {
47  continue;
48  }
49 
50  aNode->setFamily(currentFamily);
51 
52  NeighbourContainerType& innerNeighbours = aNode->getInnerNodes();
53  NeighbourContainerType& outerNeighbours = aNode->getOuterNodes();
54  NeighbourContainerType neighbours;
55  neighbours.reserve(innerNeighbours.size() + outerNeighbours.size());
56  neighbours.insert(neighbours.end(), innerNeighbours.begin(), innerNeighbours.end());
57  neighbours.insert(neighbours.end(), outerNeighbours.begin(), outerNeighbours.end());
58 
59  while (neighbours.size() != 0) {
60  neighbours = markNodes(currentFamily, neighbours);
61  }
62  currentFamily++;
63  }
64  return currentFamily;
65  }
NeighbourContainerType markNodes(short family, const NeighbourContainerType &neighbours)
Assign family to all connected nodes and return their neighbours.
NodeType
Enum of possible Nodes in parsing tree.

The documentation for this class was generated from the following file: