diff --git a/Makefile b/Makefile index 2d522e0..ce1f747 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # +-------------+---------+-----------------------+ # | John Breaux | jab0910 | JohnBreaux@my.unt.edu | # +-------------+---------+-----------------------+ -# | Created 2022-04-04 Edited 2022-04-16 | +# | Created 2022-04-04 Edited 2022-04-22 | # +-----------------------------------------------+ # ---------- Variables listed below --------- # diff --git a/inc/graph.hpp b/inc/graph.hpp index df1ff29..dce5491 100644 --- a/inc/graph.hpp +++ b/inc/graph.hpp @@ -1,9 +1,14 @@ +#ifndef PROJECT2_GRAPH_HPP_INCLUDED +#define PROJECT2_GRAPH_HPP_INCLUDED + +#include // string +#include // vector, vector + class graph { public: // Constructors graph() {} - graph(const int processes, const int resources); // Initializers: // Read a graph from a file void read(std::string filename); @@ -29,4 +34,6 @@ private: std::vector resource_counts; struct m matrix; // Tell me, Mr. Anderson, what good is a phone call if you are unable to speak? bool is_blocked(int process_id); -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/src/graph.cpp b/src/graph.cpp index 01e2e86..d60a78a 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -1,27 +1,10 @@ -#include -#include -#include +/* +-------------+---------+-----------------------+ + | John Breaux | jab0910 | JohnBreaux@my.unt.edu | + +-------------+---------+-----------------------+ + | Created 2022-04-17 | + +-----------------------------------------------+ */ #include "graph.hpp" -graph::graph (const int processes, const int resources) { - num_processes = processes; - num_resources = resources; - matrix.x = processes + resources; - matrix.y = matrix.x; - // Reserve correct number of entries to minimize reallocation - matrix.data.reserve(matrix.x); - for (int x = 0; x < matrix.x; x++) { - // Make a new x (vector) - matrix.data.push_back({}); - // Reserve correct number of entries - matrix.data[x].reserve(matrix.y); - for (int y = 0; y < matrix.y; y++) { - // Make a new y (int) - matrix.data[x].push_back({}); - } - } -} - void graph::print () { printf("np: %d\tnr: %d\n", num_processes, num_resources); printf("resource_counts:\n"); for (auto e: resource_counts) printf("%d\t", e); printf("\n"); diff --git a/src/main.cpp b/src/main.cpp index b11baf9..6dc095f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,9 +4,6 @@ +-------------+---------+-----------------------+ | Created 2022-04-16 | +-----------------------------------------------+ */ -#include -#include -#include #include "graph.hpp" // Graph reduction/Knot detection, struct adjmatrix int main(int argc, char** argv) { diff --git a/src/read_input.cpp b/src/read_input.cpp index 0fc4b58..f042205 100644 --- a/src/read_input.cpp +++ b/src/read_input.cpp @@ -1,8 +1,9 @@ -//TODO: Include C file IO header (stdio.h? Whatever it is) -#include +/* +-------------+---------+-----------------------+ + | John Breaux | jab0910 | JohnBreaux@my.unt.edu | + +-------------+---------+-----------------------+ + | Created 2022-04-17 | + +-----------------------------------------------+ */ #include -#include -#include #include #include "graph.hpp" diff --git a/src/reducible.cpp b/src/reducible.cpp index d2c9a26..6503613 100644 --- a/src/reducible.cpp +++ b/src/reducible.cpp @@ -1,6 +1,8 @@ -#include -#include -#include +/* +-------------+---------+-----------------------+ + | John Breaux | jab0910 | JohnBreaux@my.unt.edu | + +-------------+---------+-----------------------+ + | Created 2022-04-22 | + +-----------------------------------------------+ */ #include "graph.hpp" /* reducible: