Adding graphs data structure and functions in Java