Better to add data or new node as parameter

This is a discussion on Better to add data or new node as parameter within the C++ Programming forums, part of the General Programming Boards category; I'm learning graphs and I am building a digraph via adjacent list, so I'm going to use an array of ...

Better to add data or new node as parameter

I'm learning graphs and I am building a digraph via adjacent list, so I'm going to use an array of ptrs, so each index in array stores head ptr to a linked list of adjacente vertices where first node is the starting vertex to which all nodes in this indice are adjacent to.

Is it better to store pass the data and create new node inside function or better to create new node outside function and then pass that as parameter to my insert_to_end function: