# Should I separate algorithms that rely on a data structure into different classes

I'm learning about graph algorithms, so to learn them better I'm beginning to write some of them using c++. For example, I created the code for implementing the Depth First Search algorithm. Here's the class structure I have:

``````template<class T>
class Graph
{
public:

struct Edge
{
T src, dest;

};

struct visitCounts
{
int preVisitNum, postVisitNum;
};

// Default constructor
Graph() {}

// Graph Constructor
Graph(std::vector<Edge> const &edges, T startingNode);

void DFS();

void restartDFS();

void explore(T vertex);

void previst(T vertex);

void postvist(T vertex);

// Prints the PreVisit and Post Visit numbers for each node in the graph
void printPrePostVisits();

void printGraph();

// Finds nodes that have not been visited yet
// Returns a vector of unvisited nodes
std::vector<T> findUnvisitedNodes();

private:

// Static integer to keep track of the number of visits we have done in total
static int currVisitNum;

// Node where we start our DFS search
T startingNode_;

// marks which nodes have been visited. True = visited, false = not visited
std::unordered_map<T, bool> visited_;

// Keeps count the pre/post numbering for each node T
std::unordered_map<T, visitCounts> visitCountMap_;

I plan on writing more algorithms such as Bread-first Search, Dijkstra's,etc. I'm wondering if I should separate the algorithms into different classes and not just put them inside the `Graph` class. For example, `DFS`, `Dijkstra`, classes or perhaps just have a separate class that it's just for graph algorithms. Wondering what are the tradeoffs.