Dealing with std::List in std::Map for operator==,operator!= etc
<p>I am trying to understand Directed Graph implementation (without Boost library that is mentioned alot),just trying to learn things in c++. Here is what I came up with reading various pointers on different questions. I figured I could use a map to look up certain places within the graph and a list to hold the links together.</p>

<p>So the key would be say the first one to be added to the list and those that it links to would be the value held as a list  </p>

<p>This gives </p>

<p><em>key</em> John<br>
<em>value</em> list<br>
<em>list</em> Taylor->Larry->Sarah</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;list&gt;

class Graph {
    public:
        typedef std::map &lt;std::string, std::list&lt;std::string&gt; &gt; MapType;
        MapType am; // adjacency map

        Graph() {
        }

        void addVertex(std::string s) {
            if(!am[s]){ // Trying to check if the key has been defined before
            std::list&lt;std::string&gt; l;
            am[s]=l;
            }       
        }

        void addEdge(std::string s1, std::string s2) {
            addVertex(s1);
            addVertex(s2);
            am[s1].push_back(s2);
        }

};


int main (int argc, char *argv[] ){
    Graph *people;
    people = new Graph();
    people-&gt;addVertex("John");
    people-&gt;addEdge("John","Taylor");

}
</code></pre>

<p>What is the proper way to check whether a key in a map has been defined before for a list as the value?<br>
I know that for   </p>

<pre><code>std::map &lt;std::string, int &gt;
</code></pre>

<p>the default for unassigned keys is 0 so I would just use <code>!am[s]</code> to check is string s is defined.</p>

<p>For a list it starts off with an error saying there is no match for the operator, which I assume it is talking about the List I am using as the values.</p>

<p>I tried using <code>if(am[s].empty()){</code> but I don't think that gets what I am looking for.</p>
