Updated most functions to accept directed graphs in addition to undirected graphs