Feature analysis of diagrams with applications to retrieval and classification