I doubt that a distributed implementation will help.
The problem is based on the graph traversal process in which you identify each of the 2-way neighbors. To do this, each instance in a distributed version of the algorithm needs a copy of the graph:
In the latter case, each instance needs the entire graph. You will probably find that the time taken to distribute the graph to instances exceeds any acceleration of the purely parallel phase.
An alternative is to split the graph and send each instance of a portion of the graph. But then you presented the problem that the instance must talk to another instance to find out about the nodes of the graph that are not part of its graph, and this will probably lead to a denial of parallelism.
(Generally, distributed solutions work best if you don't need to move a lot of data between instances, and if calculations can be pretty much done by instances without talking to others. The cost of communication and synchronization between instances tends to kill parallelism.)
Not. If you want to parallelize this, it is best to use multithreading in one JVM. To get the maximum performance for this implementation of the algorithm, set the number of threads to the same as the number of available processors. Creating more threads than this will make the situation worse, not better. (And not bothering with thread schedules ... this will not help.)
Having said that, I suspect that the real reason for slow computation lies in the details of the algorithm and how data structures are implemented.
There is no magic "programming technique" that can quickly make a slow algorithm ... without change.
(One approach that works is to profile your code, determine where most of the time is spent, and ... after deep thinking about it ... redesign the code / data structure to improve it. no magic. Just hard work and thinking.)
source share