Public Member Functions | Private Attributes | List of all members
cvn::GCNGraph Class Reference

GCNGraph, basic input for the GCN. More...

#include <GCNGraph.h>

Public Member Functions

 GCNGraph ()
 Default constructor. More...
 
 GCNGraph (std::vector< std::vector< float >> positions, std::vector< std::vector< float >> features)
 Constructor with position and feature vectors. More...
 
 GCNGraph (std::vector< GCNGraphNode > nodes)
 Construct graph from a vector of GCNGraphNodes. More...
 
 ~GCNGraph ()
 Destructor. More...
 
void AddNode (std::vector< float > position, std::vector< float > features)
 Add a new node. More...
 
void AddNode (std::vector< float > position, std::vector< float > features, std::vector< float > groundTruth)
 
void AddNode (GCNGraphNode node)
 
const unsigned int GetNumberOfNodes () const
 Get the number of nodes. More...
 
const GCNGraphNodeGetNode (const unsigned int index) const
 Access nodes. More...
 
GCNGraphNodeGetNodeEditable (const unsigned int index)
 
const std::vector< std::pair< float, float > > GetMinMaxPositions () const
 Return minimum and maximum position coordinate values. More...
 
const std::pair< float, float > GetCoordinateMinMax (unsigned int index) const
 
const std::vector< float > GetSpacialExtent () const
 Get the extent in each dimension. More...
 
const float GetCoordinateSpacialExtent (unsigned int index) const
 
const std::vector< float > ConvertGraphToVector () const
 Function to linearise the graph to a vector for zlib file creation. More...
 
const unsigned int GetNumberOfNodeCoordinates () const
 Return the number of coordinates for each node. More...
 
const unsigned int GetNumberOfNodeFeatures () const
 Return the number of features for each node. More...
 

Private Attributes

std::vector< GCNGraphNodefNodes
 Store the nodes. More...
 

Detailed Description

GCNGraph, basic input for the GCN.

Definition at line 18 of file GCNGraph.h.

Constructor & Destructor Documentation

cvn::GCNGraph::GCNGraph ( )

Default constructor.

Definition at line 16 of file GCNGraph.cxx.

17  {}
cvn::GCNGraph::GCNGraph ( std::vector< std::vector< float >>  positions,
std::vector< std::vector< float >>  features 
)

Constructor with position and feature vectors.

Definition at line 25 of file GCNGraph.cxx.

26  {
27  if(positions.size() != features.size()){
28  std::cerr << "The number of nodes must be the same for the position and feature vectors" << std::endl;
29  assert(0);
30  }
31  for(unsigned int n = 0; n < positions.size(); ++n){
32  this->AddNode(positions.at(n),features.at(n));
33  }
34  }
void AddNode(std::vector< float > position, std::vector< float > features)
Add a new node.
Definition: GCNGraph.cxx:37
std::void_t< T > n
QTextStream & endl(QTextStream &s)
cvn::GCNGraph::GCNGraph ( std::vector< GCNGraphNode nodes)

Construct graph from a vector of GCNGraphNodes.

Definition at line 19 of file GCNGraph.cxx.

19  :
20  fNodes(nodes)
21  {
22 
23  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
cvn::GCNGraph::~GCNGraph ( )
inline

Destructor.

Definition at line 29 of file GCNGraph.h.

29 {};

Member Function Documentation

void cvn::GCNGraph::AddNode ( std::vector< float >  position,
std::vector< float >  features 
)

Add a new node.

Definition at line 37 of file GCNGraph.cxx.

37  {
38  GCNGraphNode newNode(position,features);
39  AddNode(newNode);
40  }
void AddNode(std::vector< float > position, std::vector< float > features)
Add a new node.
Definition: GCNGraph.cxx:37
void cvn::GCNGraph::AddNode ( std::vector< float >  position,
std::vector< float >  features,
std::vector< float >  groundTruth 
)

Definition at line 43 of file GCNGraph.cxx.

44  {
45  GCNGraphNode newNode(position,features,groundTruth);
46  AddNode(newNode);
47  }
void AddNode(std::vector< float > position, std::vector< float > features)
Add a new node.
Definition: GCNGraph.cxx:37
void cvn::GCNGraph::AddNode ( cvn::GCNGraphNode  node)

Definition at line 49 of file GCNGraph.cxx.

49  {
50  fNodes.push_back(node);
51  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
const std::vector< float > cvn::GCNGraph::ConvertGraphToVector ( ) const

Function to linearise the graph to a vector for zlib file creation.

Definition at line 138 of file GCNGraph.cxx.

138  {
139 
140  std::vector<float> nodeVector;
141 
142  for(const GCNGraphNode &node : fNodes){
143  // First add the position components
144  for(const float pos : node.GetPosition()){
145  nodeVector.push_back(pos);
146  }
147  // Now add the features
148  for(const float feat : node.GetFeatures()){
149  nodeVector.push_back(feat);
150  }
151  // Now add the ground truth
152  for (const float truth : node.GetGroundTruth()) {
153  nodeVector.push_back(truth);
154  }
155  }
156 
157  return nodeVector;
158  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
const std::pair< float, float > cvn::GCNGraph::GetCoordinateMinMax ( unsigned int  index) const

Definition at line 105 of file GCNGraph.cxx.

105  {
106  if(coord > fNodes.size()){
107  std::cerr << "Node index is out of bounds" << std::endl;
108  assert(0);
109  }
110  return this->GetMinMaxPositions()[coord];
111  }
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
const std::vector< std::pair< float, float > > GetMinMaxPositions() const
Return minimum and maximum position coordinate values.
Definition: GCNGraph.cxx:78
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
QTextStream & endl(QTextStream &s)
const float cvn::GCNGraph::GetCoordinateSpacialExtent ( unsigned int  index) const

Definition at line 126 of file GCNGraph.cxx.

126  {
127  if(coord > fNodes.size()){
128  std::cerr << "Node index is out of bounds" << std::endl;
129  assert(0);
130  }
131  return this->GetSpacialExtent()[coord];
132  }
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
const std::vector< float > GetSpacialExtent() const
Get the extent in each dimension.
Definition: GCNGraph.cxx:114
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
QTextStream & endl(QTextStream &s)
const std::vector< std::pair< float, float > > cvn::GCNGraph::GetMinMaxPositions ( ) const

Return minimum and maximum position coordinate values.

Definition at line 78 of file GCNGraph.cxx.

78  {
79 
80  std::pair<float,float> dummyPair = std::make_pair(1.e6,-1.e6);
81  std::vector<std::pair<float,float>> minMaxVals;
82 
83  if(fNodes.size() == 0){
84  std::cerr << "No nodes found in the graph, returning empty vector" << std::endl;
85  return minMaxVals;
86  }
87 
88  // Initialise the vector of pairs for the number of coordinates
89  for(unsigned int i = 0; i < GetNumberOfNodeCoordinates(); ++i){
90  minMaxVals.push_back(dummyPair);
91  }
92 
93  for(GCNGraphNode node : fNodes){
94  std::vector<float> nodePos = node.GetPosition();
95  for(unsigned int p = 0; p < nodePos.size(); ++p){
96  if(nodePos[p] < minMaxVals[p].first) minMaxVals[p].first = nodePos[p];
97  if(nodePos[p] > minMaxVals[p].second) minMaxVals[p].second = nodePos[p];
98  }
99  }
100 
101  return minMaxVals;
102 
103  }
const unsigned int GetNumberOfNodeCoordinates() const
Return the number of coordinates for each node.
Definition: GCNGraph.cxx:161
p
Definition: test.py:223
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
QTextStream & endl(QTextStream &s)
const GCNGraphNode & cvn::GCNGraph::GetNode ( const unsigned int  index) const

Access nodes.

Definition at line 59 of file GCNGraph.cxx.

59  {
60  if(this->GetNumberOfNodes() == 0){
61  std::cerr << "GCNGraph::GetNode(): Can't access node with index " << index << std::endl;
62  assert(0);
63  }
64 
65  return fNodes.at(index);
66  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
const unsigned int GetNumberOfNodes() const
Get the number of nodes.
Definition: GCNGraph.cxx:54
QTextStream & endl(QTextStream &s)
GCNGraphNode & cvn::GCNGraph::GetNodeEditable ( const unsigned int  index)

Definition at line 68 of file GCNGraph.cxx.

68  {
69  if(this->GetNumberOfNodes() == 0){
70  std::cerr << "GCNGraph::GetNode(): Can't access node with index " << index << std::endl;
71  assert(0);
72  }
73 
74  return fNodes.at(index);
75  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
const unsigned int GetNumberOfNodes() const
Get the number of nodes.
Definition: GCNGraph.cxx:54
QTextStream & endl(QTextStream &s)
const unsigned int cvn::GCNGraph::GetNumberOfNodeCoordinates ( ) const

Return the number of coordinates for each node.

Definition at line 161 of file GCNGraph.cxx.

161  {
162  if(fNodes.size() == 0){
163  std::cerr << "Graph has no nodes, returning 0" << std::endl;
164  return 0;
165  }
166  else return fNodes[0].GetNumberOfCoordinates();
167  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
QTextStream & endl(QTextStream &s)
const unsigned int cvn::GCNGraph::GetNumberOfNodeFeatures ( ) const

Return the number of features for each node.

Definition at line 170 of file GCNGraph.cxx.

170  {
171  if(fNodes.size() == 0){
172  std::cerr << "Graph has no nodes, returning 0" << std::endl;
173  return 0;
174  }
175  else return fNodes[0].GetNumberOfFeatures();
176  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
QTextStream & endl(QTextStream &s)
const unsigned int cvn::GCNGraph::GetNumberOfNodes ( ) const

Get the number of nodes.

Definition at line 54 of file GCNGraph.cxx.

54  {
55  return fNodes.size();
56  }
std::vector< GCNGraphNode > fNodes
Store the nodes.
Definition: GCNGraph.h:64
const std::vector< float > cvn::GCNGraph::GetSpacialExtent ( ) const

Get the extent in each dimension.

Definition at line 114 of file GCNGraph.cxx.

114  {
115 
116  std::vector<std::pair<float,float>> minMaxVals = this->GetMinMaxPositions();
117 
118  std::vector<float> extent;
119  for(std::pair<float,float> pair : minMaxVals){
120  extent.push_back(pair.second - pair.first);
121  }
122 
123  return extent;
124  }
const std::vector< std::pair< float, float > > GetMinMaxPositions() const
Return minimum and maximum position coordinate values.
Definition: GCNGraph.cxx:78

Member Data Documentation

std::vector<GCNGraphNode> cvn::GCNGraph::fNodes
private

Store the nodes.

Definition at line 64 of file GCNGraph.h.


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