more flexible defgraphfn