utils.py rewritten using NetworkX and normalize fn