A framework for bow tie analysis of directed graphs