works in progress for network improvement

the nodes and links are now pointing to each other. Also packaging
things into functions