Directed graphics processing in Java

I am looking to implement a Java application that will compute a set of tasks to execute. Tasks will depend on each other, forming a directed graph. Is there an existing SDK or algorithm (preferably in Java) that will help me:

  • Define a task schedule
  • Make sure there are no cyclic dependencies in the graph.
  • Perform tasks on a chart using a thread pool

Step 3 is the most important part. I need to execute tasks in parallel to ensure maximum performance, but make sure that the task is not running before its dependencies.

+7
source share
4 answers

Take a look at the previous question , which essentially suggests using JGraphT .

Obviously, it will make 1) easy and has loop detectors for part 3). Do not think that this will be done for you by part 3, but all you need to do is get all the vertices with a degree (or depending on your idea) of 0 and start these tasks. When the task ends, remove the vertex from the graph and start again.

+2
source

Dexecutor for rescue, Dexecutor is designed to reliably perform dependent independent tasks.

DexecutorConfig<Integer, Integer> config = new DexecutorConfig<>(executorService, new SleepyTaskProvider()); DefaultDexecutor<Integer, Integer> executor = new DefaultDexecutor<Integer, Integer>(config); // Graph building executor.addDependency(1, 2); executor.addDependency(1, 2); executor.addDependency(1, 3); executor.addDependency(3, 4); executor.addDependency(3, 5); executor.addDependency(3, 6); executor.addDependency(2, 7); executor.addDependency(2, 9); executor.addDependency(2, 8); executor.addDependency(9, 10); executor.addDependency(12, 13); executor.addDependency(13, 4); executor.addDependency(13, 14); executor.addIndependent(11); //Execution executor.execute(ExecutionConfig.NON_TERMINATING); 

Read more about How do I? More details

Why Dekecutor

  • Ultra light weight
  • Ultra fast
  • Immediate / scheduled repeat logic is supported.
  • Unconfigured behavior is supported.
  • Conditionally refuse to complete a task
  • Good testing coverage to protect you from harm.
  • Available at maven center
  • Good amount of documentation
  • Distribute Performance (Ignite, Hazelcast, Infinispan)

useful links

Disclaimer: I am the owner

+2
source

I created a Java library that does exactly what you request. You can build a directed graph consisting of Runnable objects and their dependencies. Then you pass this graph to the executor, which runs the objects, since their dependencies are executed in the executor.

Download the jar library file here: https://github.com/idooley/DAGExecutor/downloads

Or clone the entire repository and compile it yourself: https://github.com/idooley/DAGExecutor

Hope this will be helpful to others. Feel free to make any corrections, new unit tests or other changes to make them work the way you want for your projects.

+1
source

I use JUNG to create dependencies between files. There are many classes for calculating distances, clustering, etc.

0
source

All Articles