write a code for BFS Traversal
<p>I'm trying to write a code for BFS Traversal.
Unable to cast the <code>IDictionary</code> to <code>Hashtable();</code>
also unable to use Set adjacent = map[node1];
If any one can help me with this.</p>

<pre><code>class Graph
{

    private Dictionary&lt;string, HashSet&lt;string&gt;&gt; map = new Hashtable();     

    public virtual void addEdge(string node1, string node2)
    {
        HashSet&lt;string&gt; adjacent = map[node1];
        if (adjacent == null)
        {
            adjacent = new HashSet&lt;string&gt;();
            map[node1] = adjacent;
        }
        adjacent.Add(node2);
    }

    public virtual void addTwoWayVertex(string node1, string node2)
    {
        addEdge(node1, node2);
        addEdge(node2, node1);
    }

    public virtual bool isConnected(string node1, string node2)
    {
        Set adjacent = map[node1];
        if (adjacent == null)
        {
            return false;
        }
        return adjacent.contains(node2);
    }

    public virtual LinkedList&lt;string&gt; adjacentNodes(string last)
    {
        HashSet&lt;string&gt; adjacent = map[last];
        if (adjacent == null)
        {
            return new LinkedList&lt;string&gt;();
        }
        return new LinkedList&lt;string&gt;(adjacent);
    }

}
</code></pre>
