Warning: control reaches end of non-void function C++
<p>I am trying to implement Prims algorithm to find minimum spanning trees of a given graph.
The code now compiles, but the executable (instead of printing the MST) prints "segmentation fault:11". Moreover, I get a warning, : </p>

<pre><code>Warning: control reaches end of non-void function
</code></pre>

<p>Is anybody able to help me understand what's wrong with it? Thanks in advance.</p>

<pre><code>double Graph::getWeight(int v, int w)
{
    if(edge(v,w))
    {
        Node* t = adj[v];
        while(t != NULL)
        {
            t = t-&gt;next;
            if((t -&gt;v) == w)
            return t-&gt;weight;
        }
    }
}
</code></pre>
