Code cleanup and stylization
This commit is contained in:
@@ -1,34 +1,41 @@
|
||||
|
||||
#ifndef PROJECT2_GRAPH_HPP_INCLUDED
|
||||
#define PROJECT2_GRAPH_HPP_INCLUDED
|
||||
#ifndef PROJECT2_INC_GRAPH_HPP
|
||||
#define PROJECT2_INC_GRAPH_HPP
|
||||
|
||||
#include <string> // string
|
||||
#include <vector> // vector<int>, vector<vector<int>
|
||||
|
||||
typedef std::vector<std::vector<int>> matrix;
|
||||
|
||||
class graph {
|
||||
public:
|
||||
public:
|
||||
// Constructors
|
||||
graph() {}
|
||||
graph () {}
|
||||
// Initializers:
|
||||
// Read a graph from a file
|
||||
int read(std::string filename);
|
||||
int read (std::string filename);
|
||||
// Error codes given off by read ()
|
||||
enum ERROR { INVALID_PROCESSES = 0b000001,
|
||||
INVALID_RESOURCES = 0b000010,
|
||||
INVALID_COUNTS = 0b000100,
|
||||
INVALID_ROWS = 0b001000,
|
||||
INVALID_COLUMNS = 0b010000,
|
||||
INVALID_FILENAME = 0b100000 };
|
||||
|
||||
// check functions:
|
||||
// is the graph...
|
||||
bool reducible();// ?
|
||||
bool knotted();// ?
|
||||
bool reducible (); // ?
|
||||
bool knotted (); // ?
|
||||
|
||||
// miscellaneous functions:
|
||||
// print the graph
|
||||
void print ();
|
||||
|
||||
typedef std::vector<std::vector<int>> matrix;
|
||||
|
||||
private:
|
||||
private:
|
||||
int num_processes = 0;
|
||||
int num_resources = 0;
|
||||
std::vector<int> resource_counts;
|
||||
matrix m; // Tell me, Mr. Anderson, what good is a phone call if you are unable to speak?
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // PROJECT2_INC_GRAPH_HPP
|
||||
28
inc/read.hpp
Normal file
28
inc/read.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef PROJECT2_INC_READ_HPP
|
||||
#define PROJECT2_INC_READ_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/* stovi:
|
||||
* convert string s to vector<int> no matter the cost
|
||||
|
||||
@param &s const reference to a string
|
||||
|
||||
@returns vector<int>: signed integer representations
|
||||
of the groups of contiguous digits in the string
|
||||
*/
|
||||
std::vector<int> stovi (const std::string &s);
|
||||
|
||||
/* print_errpr_message:
|
||||
* Print the error message associated with the given error number
|
||||
|
||||
@param error int representing the error states of graph::read()
|
||||
@param filename string containing the name of a file
|
||||
|
||||
@returns void
|
||||
|
||||
*/
|
||||
void print_error_message (int error, std::string filename);
|
||||
|
||||
#endif // PROJECT2_INC_READ_HPP
|
||||
Reference in New Issue
Block a user