Add directed graph utility from chapter 7