graph creation and database connect