refactored open and close graph, added graph.clear, fixed bugs due to that