improve java graph initialization