Library for constructing pinch graphs and cactus graphs