Changes to be committed: new file: Graph.cpp 1) Moved the actual declarations of functions from Graph.h into this file 2) Added get_p_edges() which will get all the edges from a specified point p 3) Added add_edge() which adds an edge between two points (start and end) modified: graph.h 1) Created initial function, constructor, and deconstructor declarations 2) Defined Point structure 3) Defined Edge structure modified: main.cpp 1) Removed any old code from my last project. I am starting clean on this file.
41 lines
821 B
C++
41 lines
821 B
C++
#ifndef GRAPH_H
|
|
#define GRAPH_H
|
|
#include <new>
|
|
#include <utility>
|
|
|
|
struct Point {
|
|
float x, y, z;
|
|
int first_edge = -1;
|
|
int e_count = 0;
|
|
};
|
|
|
|
struct Edge {
|
|
int target_point;
|
|
float e_weight;
|
|
};
|
|
|
|
class Graph {
|
|
private:
|
|
Point* all_points = nullptr;
|
|
Edge* all_edges = nullptr;
|
|
size_t next_possible_edge = 0;
|
|
size_t p_capacity = 0;
|
|
size_t e_capacity = 0;
|
|
|
|
public:
|
|
Graph(size_t maxPoints, size_t maxEdges) noexcept;
|
|
~Graph();
|
|
|
|
// Move constructor
|
|
Graph(Graph&& other) noexcept;
|
|
|
|
Edge* get_p_edges(int p_index) noexcept;
|
|
|
|
void add_edge(int start_point_index, int end_point_index) noexcept;
|
|
|
|
//Preventing mem-spikes by preventing copying and enforcing deletions.
|
|
Graph(const Graph&) = delete;
|
|
Graph& operator=(const Graph&) = delete;
|
|
};
|
|
|
|
#endif |