basic function adding nodes and edges