Implement directed graph