added directed graph functionality