class for undirected and directed graphs now