On branch main

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.
This commit is contained in:
Rapturate
2026-02-28 13:15:45 -05:00
parent d174643ed2
commit da3408dcb7
3 changed files with 131 additions and 95 deletions

76
graph.h
View File

@@ -1,51 +1,41 @@
#pragma once
#include <iostream>
#include <random>
#include <vector>
#ifndef GRAPH_H
#define GRAPH_H
#include <new>
#include <utility>
using namespace std;
struct Point {
float x, y, z;
int first_edge = -1;
int e_count = 0;
};
class graph {
struct Point {
private:
string name;
int x;
int y;
vector<Point*> edges[5];
Point() : name("Unnamed"), x(0), y(0) {};
Point(string new_name, int new_x, int new_y) : name(new_name), x(new_x), y(new_y) {};
Point(string new_name, int new_x, int new_y, Point* edge) : name(new_name), x(new_x), y(new_y) {
edges->push_back(edge);
};
};
struct Edge {
int target_point;
float e_weight;
};
class Graph {
private:
Point* start;
Point* end;
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:
//class constructor
graph() : start(nullptr), end(nullptr) {};
Graph(size_t maxPoints, size_t maxEdges) noexcept;
~Graph();
// Move constructor
Graph(Graph&& other) noexcept;
Edge* get_p_edges(int p_index) noexcept;
int rand_int() {};
void del_all_data(){};
void del_element(int){};
void insert(int, int, vector<Point*>){};
void gen_list(int){};
void print_graph(){};
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;
};
//Setters
int rand_int() {
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<int> dist(1, 30);
return dist(gen);
}
//Mutators
};
#endif