Q:

Error: missing return statement in methods maxDegree and minDegree

**Im getting a compiling error telling me that I'm missing return statements in methods maxDegree and minDegree but I already have them.  I'm not sure how to fix the error.  Can someone please help?*
    private int degree( int i )
    {
        return inDegree(i) + outDegree(i); 
    }

    public int maxDegree()
    {
        int max = 0;

        for( int node = 0; node < g.length; node++ )
        {
            if( degree(node) > max ) 
            {
                return degree(node);
            }
        }
    }

    public int minDegree()
    {
        int min = g.length-1;

        for( int node = 0; node < g.length; node++ )
        {
            if( degree(node) < min ) 
            {
                return degree(node);
            }
        }
    }

} // End Graph Class

A:

The problem is that, in both methods, if you don't enter the if statement, you never reach the return. So you have to add a return at the end of the method, in the case that you never reach the return statement in the if.
public int maxDegree()
{
    int max = 0;

    for( int node = 0; node < g.length; node++ )
    {
        if( degree(node) > max ) 
        {
            return degree(node);
        }
    }

    // MISSING A RETURN OF A DEFAULT VALUE HERE
}

public int minDegree()
{
    int min = g.length-1;

    for( int node = 0; node < g.length; node++ )
    {
        if( degree(node) < min ) 
        {
            return degree(node);
        }
    }

    // MISSING A RETURN OF A DEFAULT VALUE HERE
}

EDIT this may be the code you're looking for:
public int maxDegree()
{
    int max = degree(g[0]);

    for( int node = 1; node < g.length; node++ )
    {
        if( degree(g[node]) > max ) 
        {
            max = degree(g[node]);
        }
    }

    return max;
}

public int minDegree()
{
    int min = degree(g[0]);

    for( int node = 1; node < g.length; node++ )
    {
        if( degree(g[node]) < min ) 
        {
            min = degree(g[node]);
        }
    }

    return min;
}

