Refactor *_work and execute_graph.

This commit does not modify anything in the functionality. It is a minor refactoring of the code. I found out that the function `execute_graph` gives its `work_func` parameter directly to `pthread_create`, but it also expects a certain behavior from these functions. This implies a certain amount of boilerplate code on the part of the actual worker functions.

I factored this boilerplate code out to a separate function named `run_thread`. This function now calls the actual worker functions that accept the graph and the node as their parameters. This way the code is a little bit clearer and easier to understand.