  We develop a theory of confluence of graphs. We describe an algorithm for
proving that a given system of reduction rules for abstract graphs and graphs
in surfaces is locally confluent. We apply this algorithm to show that each
simple Lie algebra of rank at most 2, gives rise to a confluent system of
reduction rules of graphs (via Kuperberg's spiders) in an arbitrary surface. As
a further consequence of this result, we find canonical bases of SU_3-skein
modules of cylinders over orientable surfaces.
