Skip to content

Commit

Permalink
Added header comments for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedcolbert committed May 4, 2022
1 parent 3d59230 commit 11a4703
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
16 changes: 0 additions & 16 deletions province.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@

using namespace std;

/*
* Constructor
* @param source File containing province:
* 1. One line: number of towns (n), number of roads (p)
* as integers
* 2. n lines: names of towns, all uppercase
* 3. p lines: roads, defined as names of towns they
* connect, bridge/not bridge, and length in miles
* ex: BEVERLY DANVERS N 2.9 (connects Beverly and
* Danvers, not a bridge, 2.9 miles long)
*/

Province::Province(std::istream & source) {
// Read first line of input
source >> _numberOfTowns >> _numberOfRoads;
Expand Down Expand Up @@ -110,10 +98,6 @@ int Province::smallest(double dist[], std::list <int> toVisit,
return smallest;
}

/**
* Print the shortest route from the capital of the
* province to each of the other towns
*/
void Province::printShortestPath(std::ostream & output) const {

// if there is only one town only one town
Expand Down
44 changes: 38 additions & 6 deletions province.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include <map>
#include <queue>

/**
* towns connected by roads
*/
class Province {
public:

/**
* Constructor
* @param source Input data for province
*
* The constructor handles input data and creates a new province graph
* with town and road data
*/
Province(std::istream & source);

Expand All @@ -26,22 +26,43 @@ class Province {
* @param output Stream to print data to
*/
void printAll(int start, std::ostream & output);

/**
* Print the shortest path conections from the capital of a province
* to all other towns
*
* @param output Stream to print data to
*/
void printShortestPath(std::ostream & output) const;

/**
* Find shortest path from one town to another
*/
void findShortestPath();

/**
* Create a minimum cost spanning tree of a province
* to calculate ideal
*
* @param output Stream to print data to
*/
void minSpan(std::ostream & output) const;

/**
* Remove bridges from the graph to evaluate
* which towns would become isolated by a storm
*
* @param output Stream to print data to
*/
void removeBridges(std::ostream & output) const;

/**
* Find the articulation points of a graph
*
* @param output Stream to print data to
*/
void articulationPoints(std::ostream & output) const;

/**
* Destructor
*/
~Province() {}

private:
Expand All @@ -55,6 +76,17 @@ class Province {
*/
std::vector<int> bfs(int start) const;

/**
* Recursive helper for articulationPoints()
*
* @param u
* @param visited
* @param disc
* @param low
* @param time
* @param parent
* @param isAP
*/
void APUtil(int u, bool visited[],
int disc[], int low[], int& time, int parent,
bool isAP[]) const;
Expand Down

0 comments on commit 11a4703

Please sign in to comment.