implemented algorithm to compute color based on degree