add node and edge function but still has some bugs to fix