code for tree graph