A fast and accurate algorithm for comparative analysis of metabolic pathways