Added functionality to build a graph and traverse it.