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 20 of file HyPERGraph.cxx.

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

◆ addGlobal()

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

Implements EventReco::GraphBase.

Definition at line 27 of file HyPERGraph.cxx.

27 {
28 m_global = EventReco::Global(attributes);
29}

◆ addNode()

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

Implements EventReco::GraphBase.

Definition at line 14 of file HyPERGraph.cxx.

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

◆ buildEdgeIndices()

void EventReco::HyPERGraph::buildEdgeIndices ( )

Definition at line 31 of file HyPERGraph.cxx.

31 {
32 if (m_nNodes < 2) {
33 return; // There are no edges when the number of nodes is less than 2.
34 }
35 std::vector<int64_t> edgeIndices = range(m_nNodes);
36 for (const auto& index1 : edgeIndices) {
37 for (const auto& index2 : edgeIndices) {
38 if (index1 != index2)
39 m_edgeIndices.push_back(std::make_pair(index1, index2));
40 }
41 }
42}
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 44 of file HyPERGraph.cxx.

44 {
46 if (m_nNodes < order) {
47 return; // There are no hyperedges when the number of nodes is less than
48 // the hyperedge order.
49 }
50 std::vector<int64_t> edgeIndices = range(m_nNodes);
51 m_hyperEdgeIndices = buildCombinations(edgeIndices, order);
53}
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:47
order
Configure Herwig7.

◆ clearGraph()

void EventReco::HyPERGraph::clearGraph ( )
virtual

Definition at line 170 of file HyPERGraph.cxx.

170 {
171 m_nNodes = 0;
172 m_nEdges = 0;
173 m_nodes.clear();
174 m_edges.clear();
175 m_global = {};
176 m_edgeIndices = {};
179 m_nHyperEdges = 0;
180}

◆ 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 55 of file HyPERGraph.cxx.

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

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