Refactor repeated code: addedge and removeedge

This may be too prudent and the result is maybe too abstract. But for
people familiar with high order functions this is OK.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
#	modified:   graph.py
#
