Prevent random graph generator to create loops