Simulates a graph with nodes and edges