Implement directed weighted graph