writing linked list for inheritance graph