Fix error handling during graph construction

The ArrayBasedDirectedGraph and SharedArrayBasedDirectedGraph implementations both silently drop exceptions in the parallel worker threads.  This series fixes those to rethrow the exceptions on the main thread. Additionally, a simple sanity check for duplicate nodes is added.