Add helper function to add edges between nodes