function to calculate nodes and links
Merge https://github.com/andrewpatt24/general-work