Update graph.sh

More or less complete and bug free.