converted graph to be directed