Permalink
Browse files

minor cleanup

  • Loading branch information...
1 parent 9fef833 commit 115d615ab4612690e34652355cc7450e67f12c8b @obradovic committed Sep 27, 2012
Showing with 29 additions and 33 deletions.
  1. +1 −1 Matrix.cpp
  2. +19 −22 Matrix.h
  3. +1 −2 Node.cpp
  4. +1 −1 Node.h
  5. +0 −1 README
  6. +6 −0 README.md
  7. +1 −6 main.cpp
View
2 Matrix.cpp
@@ -18,7 +18,7 @@ using namespace std;
//
-// bfs
+// breadth-first
void Matrix::bfs()
{
bfs(myStart, 0);
View
41 Matrix.h
@@ -46,18 +46,18 @@ class Matrix
//
// HELPERS
//
- Node * up (const Node const *) const;
- Node * down (const Node const *) const;
- Node * left (const Node const *) const;
- Node * right (const Node const *) const;
- Node * traverse (int, int) const;
+ Node * up (const Node *) const;
+ Node * down (const Node *) const;
+ Node * left (const Node *) const;
+ Node * right (const Node *) const;
+ Node * traverse (int, int) const;
void findHamiltonianPath (Node *, int);
- Node * upz (const Node const *) const;
- Node * downz (const Node const *) const;
- Node * leftz (const Node const *) const;
- Node * rightz (const Node const *) const;
- Node * traversez (int, int) const;
+ Node * upz (const Node *) const;
+ Node * downz (const Node *) const;
+ Node * leftz (const Node *) const;
+ Node * rightz (const Node *) const;
+ Node * traversez (int, int) const;
void bfs (Node *, int);
@@ -75,30 +75,27 @@ class Matrix
//
// INTERNAL TYPEDEFS
//
- typedef std::vector <Node > NodeVector;
- typedef std::vector <NodeVector> NodeMatrix;
+ typedef std::vector <Node > NodeVector;
+ typedef std::vector <NodeVector> NodeMatrix;
typedef std::map < const Node, NodeVector, NodeCompare > NodeVectorMap;
//
// PRIVATE MEMBERS
//
- int mySolutionCount;
- int myOursCount;
- int myXLen;
- int myYLen;
- Node * myStart;
- NodeMatrix myMatrix;
- NodeMatrix myAdjacencyList;
+ int mySolutionCount;
+ int myOursCount;
+ int myXLen;
+ int myYLen;
+ Node * myStart;
+ NodeMatrix myMatrix;
+ NodeMatrix myAdjacencyList;
NodeVectorMap myAdjacencyMap;
// these two only used for debugging
std::vector <Node *> myCurrentPath;
bool myDebug;
-
};
-
-
#endif
View
3 Node.cpp
@@ -8,7 +8,6 @@ using namespace std;
-
//
// OBJECT ATTRIBUTES
//
@@ -152,4 +151,4 @@ ostream & operator << (ostream & theStream, const Node & theNode)
{
theStream << "(" << theNode.myX << ", " << theNode.myY << ") = " << theNode.myValue << " ";
return theStream;
-}
+}
View
2 Node.h
@@ -66,7 +66,7 @@ class Node
// BOOKKEEPERS
//
Node ();
- Node (int, int, int, int);
+ Node (int, int, int, int); // x, y, value, id
Node (const Node &);
~Node ();
View
1 README
@@ -1 +0,0 @@
-This is a simple program to calculate the Hamiltonian Path problem as posed by Quora
View
6 README.md
@@ -0,0 +1,6 @@
+HamiltonianPath
+==========
+
+This is a simple program to calculate the Hamiltonian Path problem as posed by Quora
+
+The Node and Matrix classes do all the work. Main.cpp kicks things off.
View
7 main.cpp
@@ -7,20 +7,16 @@
#include "Matrix.h"
-
-
//
// der main
//
int main (int argc, const char * argv[])
{
- // fred
Matrix fred;
// just in case
try
{
-
// reads the input from stdin
fred.read();
@@ -32,7 +28,6 @@ int main (int argc, const char * argv[])
// print the results
fred.printResults();
-
}
// woops
@@ -41,7 +36,7 @@ int main (int argc, const char * argv[])
return 1;
}
- // and return. happy happy
+ // happy happy path
return 0;
}

0 comments on commit 115d615

Please sign in to comment.