initial graph function, including a random graph generator and a connectedness test, (also some utilities)