graph optimize (not very good looking result)