ATLAS Offline Software
Loading...
Searching...
No Matches
EventReco::HyPERGraph Class Reference

#include <HyPERGraph.h>

Inheritance diagram for EventReco::HyPERGraph:
Collaboration diagram for EventReco::HyPERGraph:

Public Member Functions

 HyPERGraph ()
virtual ~HyPERGraph ()=default
virtual void addNode (const Features &attributes) override
virtual void addEdge (int64_t source, int64_t target, const Features &attributes) override
virtual void addGlobal (const Features &attributes) override
void buildEdgeIndices ()
void buildHyperEdges (int64_t order)
const std::vector< EdgeIndex > & getEdgeIndicesVector () const
HyperEdgeIndex getHyperEdgeIndices (std::size_t index) const
int64_t nHyperEdges () const
int64_t hyperEdgeOrder () const
virtual void printGraph () const
virtual void printGraphInputsForValidation () const
virtual void clearGraph ()
Features getNodeFeats (std::size_t index) const
Features & getNodeFeats (std::size_t index)
Features getEdgeFeats (std::size_t index) const
Features getGlobalFeats () const
EdgeIndex getEdgeIndicesVector (std::size_t index) const
int64_t nNodes () const
int64_t nEdges () const
int64_t nGlobal () const

Protected Attributes

std::vector< EdgeIndex > m_edgeIndices = {}
std::vector< HyperEdgeIndex > m_hyperEdgeIndices = {}
int64_t m_nHyperEdges = 0
int64_t m_hyperEdgeOrder = 0
Global m_global
std::vector< Node > m_nodes
std::vector< Edge > m_edges
int64_t m_nNodes = 0
int64_t m_nEdges = 0

Private Types

using HyperEdgeIndex = std::vector<int64_t>

Detailed Description

Definition at line 21 of file HyPERGraph.h.

Member Typedef Documentation

◆ HyperEdgeIndex

using EventReco::HyPERGraph::HyperEdgeIndex = std::vector<int64_t>
private

Definition at line 22 of file HyPERGraph.h.

Constructor & Destructor Documentation

◆ HyPERGraph()

EventReco::HyPERGraph::HyPERGraph ( )
inline

Definition at line 25 of file HyPERGraph.h.

25: GraphBase() {};

◆ ~HyPERGraph()

virtual EventReco::HyPERGraph::~HyPERGraph ( )
virtualdefault

Member Function Documentation

◆ addEdge()

void EventReco::HyPERGraph::addEdge ( int64_t source,
int64_t target,
const Features & attributes )
overridevirtual

Implements EventReco::GraphBase.

Definition at line 19 of file HyPERGraph.cxx.

20 {
21 m_edges.emplace_back(source, target, attributes);
22 m_nEdges += 1;
23}
std::vector< Edge > m_edges
Definition GraphBase.h:95

◆ addGlobal()

void EventReco::HyPERGraph::addGlobal ( const Features & attributes)
overridevirtual

Implements EventReco::GraphBase.

Definition at line 25 of file HyPERGraph.cxx.

25 {
26 m_global = EventReco::Global(attributes);
27}

◆ addNode()

void EventReco::HyPERGraph::addNode ( const Features & attributes)
overridevirtual

Implements EventReco::GraphBase.

Definition at line 14 of file HyPERGraph.cxx.

14 {
15 m_nodes.emplace_back(attributes, m_nNodes);
16 m_nNodes += 1;
17}
std::vector< Node > m_nodes
Definition GraphBase.h:94

◆ buildEdgeIndices()

void EventReco::HyPERGraph::buildEdgeIndices ( )

Definition at line 29 of file HyPERGraph.cxx.

29 {
30 if (m_nNodes < 2) {
31 return; // There are no edges when the number of nodes is less than 2.
32 }
33 std::vector<int64_t> edgeIndices = range(m_nNodes);
34 for (const auto& index1 : edgeIndices) {
35 for (const auto& index2 : edgeIndices) {
36 if (index1 != index2)
37 m_edgeIndices.push_back(std::make_pair(index1, index2));
38 }
39 }
40}
std::vector< EdgeIndex > m_edgeIndices
Definition HyPERGraph.h:49
std::vector< int64_t > range(int64_t n)

◆ buildHyperEdges()

void EventReco::HyPERGraph::buildHyperEdges ( int64_t order)

Definition at line 42 of file HyPERGraph.cxx.

42 {
44 if (m_nNodes < order) {
45 return; // There are no hyperedges when the number of nodes is less than
46 // the hyperedge order.
47 }
48 std::vector<int64_t> edgeIndices = range(m_nNodes);
49 m_hyperEdgeIndices = buildCombinations(edgeIndices, order);
51}
std::vector< HyperEdgeIndex > m_hyperEdgeIndices
Definition HyPERGraph.h:50
std::vector< std::vector< T > > buildCombinations(const std::vector< T > &elements, int64_t hyperEdgeOrder)
Definition HyPERUtils.h:48
order
Configure Herwig7.

◆ clearGraph()

void EventReco::HyPERGraph::clearGraph ( )
virtual

Definition at line 168 of file HyPERGraph.cxx.

168 {
169 m_nNodes = 0;
170 m_nEdges = 0;
171 m_nodes.clear();
172 m_edges.clear();
173 m_global = {};
174 m_edgeIndices = {};
177 m_nHyperEdges = 0;
178}

◆ getEdgeFeats()

Features EventReco::GraphBase::getEdgeFeats ( std::size_t index) const
inlineinherited

Definition at line 80 of file GraphBase.h.

80 {
81 return m_edges[index].getFeatures();
82 };
str index
Definition DeMoScan.py:362

◆ getEdgeIndicesVector() [1/2]

EdgeIndex EventReco::GraphBase::getEdgeIndicesVector ( std::size_t index) const
inlineinherited

Definition at line 84 of file GraphBase.h.

84 {
85 return m_edges[index].getIndices();
86 };

◆ getEdgeIndicesVector() [2/2]

const std::vector< EdgeIndex > & EventReco::HyPERGraph::getEdgeIndicesVector ( ) const
inline

Definition at line 35 of file HyPERGraph.h.

35 {
36 return m_edgeIndices;
37 }

◆ getGlobalFeats()

Features EventReco::GraphBase::getGlobalFeats ( ) const
inlineinherited

Definition at line 83 of file GraphBase.h.

83{ return m_global.getFeatures(); };

◆ getHyperEdgeIndices()

HyperEdgeIndex EventReco::HyPERGraph::getHyperEdgeIndices ( std::size_t index) const
inline

Definition at line 38 of file HyPERGraph.h.

38 {
40 }

◆ getNodeFeats() [1/2]

Features & EventReco::GraphBase::getNodeFeats ( std::size_t index)
inlineinherited

Definition at line 77 of file GraphBase.h.

77 {
78 return m_nodes[index].getFeatures();
79 };

◆ getNodeFeats() [2/2]

Features EventReco::GraphBase::getNodeFeats ( std::size_t index) const
inlineinherited

Definition at line 74 of file GraphBase.h.

74 {
75 return m_nodes[index].getFeatures();
76 };

◆ hyperEdgeOrder()

int64_t EventReco::HyPERGraph::hyperEdgeOrder ( ) const
inline

Definition at line 42 of file HyPERGraph.h.

42{ return m_hyperEdgeOrder; }

◆ nEdges()

int64_t EventReco::GraphBase::nEdges ( ) const
inlineinherited

Definition at line 89 of file GraphBase.h.

89{ return m_nEdges; };

◆ nGlobal()

int64_t EventReco::GraphBase::nGlobal ( ) const
inlineinherited

Definition at line 90 of file GraphBase.h.

90{ return m_global.getFeatures().size(); };

◆ nHyperEdges()

int64_t EventReco::HyPERGraph::nHyperEdges ( ) const
inline

Definition at line 41 of file HyPERGraph.h.

41{ return m_nHyperEdges; }

◆ nNodes()

int64_t EventReco::GraphBase::nNodes ( ) const
inlineinherited

Definition at line 88 of file GraphBase.h.

88{ return m_nNodes; };

◆ printGraph()

void EventReco::HyPERGraph::printGraph ( ) const
virtual

Definition at line 53 of file HyPERGraph.cxx.

53 {
54 using namespace asg::msgUserCode;
55 setMsgLevel(MSG::INFO);
56 ANA_MSG_INFO("Printing graph...");
57 // Print the nodes
58 for (const auto& node : m_nodes) {
59 ANA_MSG_INFO("Node Index: " << node.getNodeIndex());
60 for (const auto& feat : node.getFeatures()) {
61 ANA_MSG_INFO("Feature: " << feat);
62 }
63 }
64 // Print the edges
65 for (const auto& edge : m_edges) {
66 ANA_MSG_INFO("Edge Index: " << edge.getIndices().first << " -> "
67 << edge.getIndices().second);
68 for (const auto& feat : edge.getFeatures()) {
69 ANA_MSG_INFO("Feature: " << feat);
70 }
71 }
72 // Print the global
73 ANA_MSG_INFO("Global Features: ");
74 for (const auto& feat : m_global.getFeatures()) {
75 ANA_MSG_INFO("Feature: " << feat);
76 }
77 // Print the hyperedges
78 for (const auto& hyperEdge : m_hyperEdgeIndices) {
79 std::string indices{""};
80 for (const auto& index : hyperEdge) {
81 indices += std::to_string(index) + " ";
82 }
83 ANA_MSG_INFO("HyperEdge indices: " << indices);
84 }
85 ANA_MSG_INFO("Finished graph printing...");
86}
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
std::vector< std::vector< int64_t > > indices

◆ printGraphInputsForValidation()

void EventReco::HyPERGraph::printGraphInputsForValidation ( ) const
virtual

Definition at line 88 of file HyPERGraph.cxx.

88 {
89 using namespace asg::msgUserCode;
90 setMsgLevel(MSG::INFO);
91 ANA_MSG_INFO("Printing graph inputs in validation mode...");
92
93 // Print the nodes
94 ANA_MSG_INFO("NODES:");
95 for (const auto& node : m_nodes) {
96 std::string row = "[";
97 for (const auto& feat : node.getFeatures()) {
98 row += std::to_string(feat) + ", ";
99 }
100 row += "],";
101 ANA_MSG_INFO(row);
102 }
103 // Print the edges
104 ANA_MSG_INFO("EDGES:");
105 for (const auto& edge : m_edges) {
106 std::string row = "[";
107 for (const auto& feat : edge.getFeatures()) {
108 row += std::to_string(feat) + ", ";
109 }
110 row += "],";
111 ANA_MSG_INFO(row);
112 }
113 // Print the edge indices
114 ANA_MSG_INFO("EDGE INDICES:");
115 std::string row1 = "[";
116 std::string row2 = "[";
117 for (const auto& edge : m_edges) {
118 row1 += std::to_string(edge.getIndices().first) + ", ";
119 row2 += std::to_string(edge.getIndices().second) + ", ";
120 }
121 row1 += "],";
122 row2 += "],";
123 ANA_MSG_INFO(row1);
124 ANA_MSG_INFO(row2);
125 // Print the globals
126 ANA_MSG_INFO("GLOBAL:");
127 std::string row = "[[";
128 for (const auto& feat : m_global.getFeatures()) {
129 row += std::to_string(feat) + ", ";
130 }
131 row += "]],";
132 ANA_MSG_INFO(row);
133 // Print batch
134 ANA_MSG_INFO("BATCH:");
135 row = "[[";
136 for (auto i{0}; i < this->nNodes(); i++) {
137 row += "0, ";
138 }
139 row += "]],";
140 ANA_MSG_INFO(row);
141 // Print the hyperedges
142 ANA_MSG_INFO("HYPEREDGE INDICES:");
143 std::vector<std::string> rows(this->hyperEdgeOrder());
144 for (auto i{0}; i < this->hyperEdgeOrder(); i++) {
145 rows[i] = "[";
146 }
147 for (const auto& hyperEdge : m_hyperEdgeIndices) {
148 for (auto i{0}; i < this->hyperEdgeOrder(); i++) {
149 rows[i] += std::to_string(hyperEdge[i]) + ", ";
150 }
151 }
152 for (auto i{0}; i < this->hyperEdgeOrder(); i++) {
153 rows[i] += "],";
154 ANA_MSG_INFO(rows[i]);
155 }
156 // Print batch hyperedges
157 ANA_MSG_INFO("BATCH HYPEREDGES:");
158 row = "[[";
159 for (auto i{0}; i < this->nHyperEdges(); i++) {
160 row += "0, ";
161 }
162 row += "]],";
163 ANA_MSG_INFO(row);
164
165 ANA_MSG_INFO("Finished printing graph inputs for validation...");
166}
int64_t nNodes() const
Definition GraphBase.h:88
int64_t hyperEdgeOrder() const
Definition HyPERGraph.h:42
int64_t nHyperEdges() const
Definition HyPERGraph.h:41
row
Appending html table to final .html summary file.

Member Data Documentation

◆ m_edgeIndices

std::vector<EdgeIndex> EventReco::HyPERGraph::m_edgeIndices = {}
protected

Definition at line 49 of file HyPERGraph.h.

49{};

◆ m_edges

std::vector<Edge> EventReco::GraphBase::m_edges
protectedinherited

Definition at line 95 of file GraphBase.h.

◆ m_global

Global EventReco::GraphBase::m_global
protectedinherited

Definition at line 93 of file GraphBase.h.

◆ m_hyperEdgeIndices

std::vector<HyperEdgeIndex> EventReco::HyPERGraph::m_hyperEdgeIndices = {}
protected

Definition at line 50 of file HyPERGraph.h.

50{};

◆ m_hyperEdgeOrder

int64_t EventReco::HyPERGraph::m_hyperEdgeOrder = 0
protected

Definition at line 52 of file HyPERGraph.h.

◆ m_nEdges

int64_t EventReco::GraphBase::m_nEdges = 0
protectedinherited

Definition at line 97 of file GraphBase.h.

◆ m_nHyperEdges

int64_t EventReco::HyPERGraph::m_nHyperEdges = 0
protected

Definition at line 51 of file HyPERGraph.h.

◆ m_nNodes

int64_t EventReco::GraphBase::m_nNodes = 0
protectedinherited

Definition at line 96 of file GraphBase.h.

◆ m_nodes

std::vector<Node> EventReco::GraphBase::m_nodes
protectedinherited

Definition at line 94 of file GraphBase.h.


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