  We give an algorithm to decide whether an algebraic plane foliation F has a
rational first integral and to compute it in the affirmative case. The
algorithm runs whenever we assume the polyhedrality of the cone of curves of
the surface obtained after blowing-up the set B_F of infinitely near points
needed to get the dicritical exceptional divisors of a minimal resolution of
the singularities of F. This condition can be detected in several ways, one of
them from the proximity relations in B_F and, as a particular case, it holds
when the cardinality of B_F is less than 9.
