parallel version for graph