Implements directed graph class.