graph-based approach