An algorithm for 3-colorable graphs