A technique for generating Feynman diagrams