From 654fb751e63c77c85a7e698f3de28e703e26f6ae Mon Sep 17 00:00:00 2001 From: John Breaux Date: Fri, 22 Apr 2022 21:08:33 -0500 Subject: [PATCH] graph::print Create function to print a graph --- inc/graph.hpp | 7 +++++++ src/graph.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/inc/graph.hpp b/inc/graph.hpp index e6db554..df1ff29 100644 --- a/inc/graph.hpp +++ b/inc/graph.hpp @@ -5,12 +5,19 @@ public: graph() {} graph(const int processes, const int resources); // Initializers: + // Read a graph from a file void read(std::string filename); + // TODO: generate a random graph + void random(int processes, int resources); // check functions: // is the graph... bool reducible();// ? bool knotted();// ? + // miscellaneous functions: + // print the graph + void print (); + struct m{ int x, y; std::vector> data; diff --git a/src/graph.cpp b/src/graph.cpp index ca7b48b..01e2e86 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -21,3 +21,9 @@ graph::graph (const int processes, const int resources) { } } } + +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"); + printf("matrix:\n"); for (auto x: matrix.data) {for (auto y: x) printf("%d\t", y); printf("\n");} +}