diff --git a/Flat_Buffer_Graph.cpp b/fb_graph/fb_graph.cpp similarity index 81% rename from Flat_Buffer_Graph.cpp rename to fb_graph/fb_graph.cpp index a2f4d99..c79a3f6 100644 --- a/Flat_Buffer_Graph.cpp +++ b/fb_graph/fb_graph.cpp @@ -1,15 +1,15 @@ /** * @author: Lewis Price * @date: 06-09-2026 (MM-DD-YYYY) - * @brief: This file contains the class definition for the Flat_Buffer_Graph, which is a graph data structure that uses flat buffers to store points and edges. The class provides methods for adding and deleting points and edges, as well as printing the graph for debugging purposes. + * @brief: This file contains the class definition for the fb_graph, which is a graph data structure that uses flat buffers to store points and edges. The class provides methods for adding and deleting points and edges, as well as printing the graph for debugging purposes. * @version: 1.0.0 */ -#include "Flat_Buffer_Graph.h" +#include "fb_graph.h" // Begin : Construction & Deconstruction -Flat_Buffer_Graph::Flat_Buffer_Graph(size_t max_points, size_t max_edges) noexcept +fb_graph::fb_graph(size_t max_points, size_t max_edges) noexcept { all_points = new(std::nothrow) Point[max_points] {}; all_edges = new(std::nothrow) Edge[max_edges] {}; @@ -21,13 +21,13 @@ Flat_Buffer_Graph::Flat_Buffer_Graph(size_t max_points, size_t max_edges) noexce } } -Flat_Buffer_Graph::~Flat_Buffer_Graph() +fb_graph::~fb_graph() { delete[] all_points; delete[] all_edges; } -Flat_Buffer_Graph::Flat_Buffer_Graph(Flat_Buffer_Graph&& new_location) noexcept +fb_graph::fb_graph(fb_graph&& new_location) noexcept : all_points(std::exchange(new_location.all_points, nullptr)), all_edges(std::exchange(new_location.all_edges, nullptr)), p_capacity(std::exchange(new_location.p_capacity, 0)), @@ -35,7 +35,7 @@ Flat_Buffer_Graph::Flat_Buffer_Graph(Flat_Buffer_Graph&& new_location) noexcept // End : Construction & Deconstruction // ----------------------- BEGIN : Printing ----------------------- -void Flat_Buffer_Graph::print_graph() noexcept +void fb_graph::print_graph() noexcept { for (size_t i = 0; i < p_capacity; ++i) { Point& p = all_points[i]; @@ -57,12 +57,12 @@ void Flat_Buffer_Graph::print_graph() noexcept // ----------------------- BEGIN : Getters ----------------------- -Point* Flat_Buffer_Graph::get_points() noexcept +Point* fb_graph::get_points() noexcept { return all_points; } -Edge* Flat_Buffer_Graph::get_p_edges(int p_index) noexcept +Edge* fb_graph::get_p_edges(int p_index) noexcept { if(p_index < 0 || (size_t)p_index >= p_capacity) return nullptr; @@ -76,7 +76,7 @@ Edge* Flat_Buffer_Graph::get_p_edges(int p_index) noexcept // ----------------------- BEGIN : Mutators ----------------------- -Point* Flat_Buffer_Graph::add_point(std::string name, float x, float y, float z) noexcept { +Point* fb_graph::add_point(std::string name, float x, float y, float z) noexcept { int target = -1; if (next_free_point != -1) { @@ -100,7 +100,7 @@ Point* Flat_Buffer_Graph::add_point(std::string name, float x, float y, float z) } -bool Flat_Buffer_Graph::delete_point(int p_index) { +bool fb_graph::delete_point(int p_index) { if (p_index < 0 || (size_t)p_index >= p_capacity) return false; // 1. IMPORTANT: Clean up all edges belonging to this point first! @@ -119,7 +119,7 @@ bool Flat_Buffer_Graph::delete_point(int p_index) { } -Edge* Flat_Buffer_Graph::add_edge(int e_start, int e_end, float weight) noexcept { +Edge* fb_graph::add_edge(int e_start, int e_end, float weight) noexcept { // Validation: Ensure indices are within bounds if (e_start < 0 || (size_t)e_start >= p_capacity || e_end < 0 || (size_t)e_end >= p_capacity) return nullptr; @@ -148,7 +148,7 @@ Edge* Flat_Buffer_Graph::add_edge(int e_start, int e_end, float weight) noexcept return &all_edges[target_edge]; } -bool Flat_Buffer_Graph::delete_edge(int e_start, int e_end) noexcept { +bool fb_graph::delete_edge(int e_start, int e_end) noexcept { Point& p = all_points[e_start]; int current = p.first_edge; int prev = -1; diff --git a/Flat_Buffer_Graph.h b/fb_graph/fb_graph.h similarity index 84% rename from Flat_Buffer_Graph.h rename to fb_graph/fb_graph.h index f464e86..d3b952c 100644 --- a/Flat_Buffer_Graph.h +++ b/fb_graph/fb_graph.h @@ -1,7 +1,7 @@ /** * @author: Lewis Price * @date: 06-09-2026 (MM-DD-YYYY) - * @brief: This file contains the class definition for the Flat_Buffer_Graph, which is a graph data structure that uses flat buffers to store points and edges. The class provides methods for adding and deleting points and edges, as well as printing the graph for debugging purposes. + * @brief: This file contains the class definition for the fb_graph, which is a graph data structure that uses flat buffers to store points and edges. The class provides methods for adding and deleting points and edges, as well as printing the graph for debugging purposes. * @version: 1.0.0 */ @@ -39,7 +39,7 @@ struct Edge { int next_edge = -1; }; -/** @class Flat_Buffer_Graph +/** @class fb_graph * @brief Defines the default values for the private variables. * * @param next_free_point The index of the next memory location in the Point buffer, where the next added point will go. @@ -56,7 +56,7 @@ struct Edge { * @param all_points The buffer that stores all of the points in the graph. * @param all_edges The buffer that stores all the edges in the graph. */ -class Flat_Buffer_Graph { +class fb_graph { private: int next_free_point = -1; size_t num_points = 0; @@ -74,23 +74,23 @@ private: public: /** Constructor - * @brief Creates a new Flat_Buffer_Graph. - * @param max_points Maximum number of points in the Flat_Buffer_Graph. - * @param max_edges Maximum number of edges in the Flat_Buffer_Graph. + * @brief Creates a new fb_graph. + * @param max_points Maximum number of points in the fb_graph. + * @param max_edges Maximum number of edges in the fb_graph. */ - Flat_Buffer_Graph(size_t p_capacity, size_t e_capacity) noexcept; + fb_graph(size_t p_capacity, size_t e_capacity) noexcept; /** Deconstructor * @brief Deletes all_points and all_edges from memory */ - ~Flat_Buffer_Graph(); + ~fb_graph(); /** Move Constructor * @brief Instructions to move the current graph object from one memory location to another without copying. * @param new_location The new memory location to move the graph to. */ - Flat_Buffer_Graph(Flat_Buffer_Graph&& new_location) noexcept; + fb_graph(fb_graph&& new_location) noexcept; /** Debug Function: print_graph * @brief Prints all points and their edges. @@ -168,6 +168,6 @@ public: bool delete_edge(int e_start, int e_end) noexcept; //Enforcing deletions to prevent memory spikes. - Flat_Buffer_Graph(const Flat_Buffer_Graph&) = delete; - Flat_Buffer_Graph& operator=(const Flat_Buffer_Graph&) = delete; + fb_graph(const fb_graph&) = delete; + fb_graph& operator=(const fb_graph&) = delete; }; \ No newline at end of file diff --git a/fb_map/fb_map.cpp b/fb_map/fb_map.cpp new file mode 100644 index 0000000..e69de29 diff --git a/fb_map/fb_map.h b/fb_map/fb_map.h new file mode 100644 index 0000000..e69de29 diff --git a/main.cpp b/main.cpp index d0b8712..d9e88bb 100644 --- a/main.cpp +++ b/main.cpp @@ -1,17 +1,17 @@ /** * @author: Lewis Price * @date: 06-09-2026 (MM-DD-YYYY) - * @brief: This file contains the code required for running the Graph Theory project. It includes the main function and several test case graphs to demonstrate the functionality of the Flat_Buffer_Graph class. + * @brief: This file contains the code required for running the Graph Theory project. It includes the main function and several test case graphs to demonstrate the functionality of the fb_graph class. * @ * @version: 1.0.0 */ -#include "Flat_Buffer_Graph.h" +#include "fb_graph/Flat_Buffer_Graph.h" #include using namespace std; int main() { - Flat_Buffer_Graph* g = new Flat_Buffer_Graph(5, 7); + fb_graph* g = new fb_graph(5, 7); g->add_point("Charlotte", 1.2222, 1.22222, 720.73425); g->add_point("Waco", 1.1111, 1.1111, 200.00); g->add_edge(1, 1, 20);