Testing graphs in functions