If graph is undirected, set invert graph to be the same as the original input graph to reduce memory.