check if edge has attribute weight not node when processing edges; removed redundant code and unused imports