working on directed graphs functions