Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipNelson5 committed Apr 26, 2018
1 parent 05acd7c commit c8d58d1
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 324 deletions.
96 changes: 48 additions & 48 deletions CS2420_CS3/7-GraphCycles/edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@
#include <sstream>

class Edge
{
public:
int fromNode; // Subscript of other endpoint in node array
int toNode; // Subscript of one endpoint in node array. Nodes are stored as numbers, but printed as characters.
int cycleID; // Cycle which the edge is a member of, -1 if it is included in no cycle
int order;
bool used; // true if edge is used in final tour
{
public:
int fromNode; // Subscript of other endpoint in node array
int toNode; // Subscript of one endpoint in node array. Nodes are stored as numbers, but printed as characters.
int cycleID; // Cycle which the edge is a member of, -1 if it is included in no cycle
int order;
bool used; // true if edge is used in final tour

Edge(char f, char t): cycleID(-1), order(-1), used(false) { set(f, t); }//constructor with vertex letters
Edge(int f, int t): cycleID(-1), order(-1), used(false) { set(f, t); }//constructor with vertex numbers
Edge(char f, char t): cycleID(-1), order(-1), used(false) { set(f, t); }//constructor with vertex letters
Edge(int f, int t): cycleID(-1), order(-1), used(false) { set(f, t); }//constructor with vertex numbers

// Create a string version of Edge
// Edge endpoints are stored as numbers, but printed as characters.
std::string toString() const
{
std::ostringstream os; // allows string to act like stream to use stream operations
char f = fromNode + 'A';
char t = toNode + 'A';
os << f << "-" << t << " (" << cycleID << ") (" << order << ") ";
return os.str();
}
// Create a string version of Edge
// Edge endpoints are stored as numbers, but printed as characters.
std::string toString() const
{
std::ostringstream os; // allows string to act like stream to use stream operations
char f = fromNode + 'A';
char t = toNode + 'A';
os << f << "-" << t << " (" << cycleID << ") (" << order << ") ";
return os.str();
}

// if one Node is an endpoint, return other endpoint
int getOther(int oneNode) const
{
if (fromNode == oneNode) return toNode;
assert(toNode == oneNode);
return fromNode;
}
// if one Node is an endpoint, return other endpoint
int getOther(int oneNode) const
{
if (fromNode == oneNode) return toNode;
assert(toNode == oneNode);
return fromNode;
}

// Set initial values of an edge from Node f to Node t (char)
void set(char f, char t)
{
fromNode = f - 'A';
toNode = t - 'A';
cycleID = -1;
used = false;
//std::cout << "creating Edge " << toString() << std::endl;
}
// Set initial values of an edge from Node f to Node t (char)
void set(char f, char t)
{
fromNode = f - 'A';
toNode = t - 'A';
cycleID = -1;
used = false;
//std::cout << "creating Edge " << toString() << std::endl;
}

// Set initial values of an edge from Node f to Node t (int)
void set(int f, int t)
{
fromNode = f;
toNode = t;
cycleID = -1;
// Set initial values of an edge from Node f to Node t (int)
void set(int f, int t)
{
fromNode = f;
toNode = t;
cycleID = -1;

used = false;
//std::cout << "creating Edge " << toString() << std::endl;
}
used = false;
//std::cout << "creating Edge " << toString() << std::endl;
}

friend bool operator== (Edge const & a, Edge const & b)
{
return (a.fromNode == b.fromNode && a.toNode == b.toNode);
}
friend bool operator== (Edge const & a, Edge const & b)
{
return (a.fromNode == b.fromNode && a.toNode == b.toNode);
}
};

#endif
Loading

0 comments on commit c8d58d1

Please sign in to comment.