C++ implementation of depth-first search I got the C++ implementation of depth-first search (DFS) from here and made slight modifications to it. The modified code is as follows:
#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include&lt;map&gt;
#include&lt;list&gt;

class Graph {
    void DFSUtil(int v);
public:
    std::map&lt;int, bool&gt; visited;
    std::map&lt;int, std::list&lt;int&gt;&gt; adj;
    void addEdge(int v, int w);
    void DFS();
};

void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w);
}

void Graph::DFSUtil(int v)
{
    visited[v] = true;
    std::cout &lt;&lt; v &lt;&lt; &quot; &quot;;

    std::list&lt;int&gt;::iterator i;
    for (i = adj[v].begin(); i != adj[v].end(); ++i)
        if (!visited[*i])
            DFSUtil(*i);
}


void Graph::DFS()
{
    for (auto i : adj)
        if (visited[i.first] == false)
            DFSUtil(i.first);
}

int main()
{
    Graph g;
    g.addEdge(0, 1);
    g.addEdge(0, 9);
    g.addEdge(1, 2);
    g.addEdge(2, 0);
    g.addEdge(2, 3);
    g.addEdge(9, 3);

    std::cout &lt;&lt; &quot;Depth First Traversal result\n&quot;;
    g.DFS();

    std::cin.get();

    return 0;
}

What further improvements can I make to this code?
What further improvements can I make to this code?

The code is rather bad - the site you read it from tends to have lots of bad/amateur articles.

The graph class:
std::map&lt;int, bool&gt; visited;
std::map&lt;int, std::list&lt;int&gt;&gt; adj;



This is extremely poor and inefficient graph implementation. std::map creates a new memory allocation for each element. So you do it twice for both the boolean and the list. Also std::list allocates a piece of memory for each element as well.
Overuse of memory allocation means both memory fragmentation issues as well as performance issues due lots of unmanageable RAM access and indirections. Memory loading is currently one of the slowest operations on modern processors. But compilers tend to optimize it quite well if the memory is contiguous - which is furthest from the truth in this case.
To simplify the structure you'd better use std::vector&lt;Node&gt; where Node contains vertex's information + std::vector&lt;size_t&gt; of neighbors. In general, I don't believe there is a perfect solution for graph representation - instead there are numerous ways to represent and each suitable or more attuned to specific types of graphs. For instance, solutions that are good for sparse graphs are surely very poorly suited for dense graphs. Also certain additional optimizations can be made assuming that graph is fixes. The question is complex and I cannot provide an answer without knowledge of the use-case.

DFS() implementation is also pretty bad. It relies on recursion and I assure you, that for large enough connected graphs with it will blow the stack resulting in UB.

Proper DFS/BFS implementation store states-to-be-visited in a std::stack or std::queue or something similar while the visit routine occurs in a single loop instead of recursion.
Also, I presume you want some kind of output or action made on vertices from the DFS, no?