# Using Graphs to determine parallel order of execution for dependencies

**URL:** <https://discourse.julialang.org/t/using-graphs-to-determine-parallel-order-of-execution-for-dependencies/83757>\
**Category:** General Usage\
**Created:** [July 4, 2022, 8:29pm UTC](https://discourse.julialang.org/t/using-graphs-to-determine-parallel-order-of-execution-for-dependencies/83757 "2022-07-04T20:29:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Barker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jon_barker/32/18997_2.png) [@Jon\_Barker](https://discourse.julialang.org/u/Jon_Barker)\
**Post date:** [July 4, 2022, 8:29pm UTC](https://discourse.julialang.org/t/using-graphs-to-determine-parallel-order-of-execution-for-dependencies/83757/1 "2022-07-04T20:29:56Z")

</div>

Hello smart people, I have a list of operations which I want to parallelize the order. To do this, I’m using a graph of dependencies. However I’m stuck at what to do next.

I found a nice SO post that explains it well, however I’m having trouble converting the java code to Julia. I seem to be missing the removevertex part.

> <https://stackoverflow.com/questions/67337917/group-tasks-for-concurrent-processing-in-directed-acyclic-dependency-graph-using>

> <https://stackoverflow.com/questions/67265652/topological-sorting-of-a-directed-acyclic-graph-into-stages>

Here’s my code thus far cloned from the first SO article.

> g = SimpleDiGraph(all\_edges)
> 
> groups =   
> group =
> 
> for task in vertices(g)  
> x = indegree(g, task)
> 
> ```
> if x == 0 
> push!(group, task)
> end
> 
> ```
> 
> end
> 
> while true  
> push!(groups, group)  
> nextGroup =
> 
> ```
> for task in group
> for nextTask in all_neighbors(g, task)
> if indegree(g, nextTask) == 1
> push!(nextGroup, nextTask)
> end
> end
> 
> removeVertex(g, task) #HMMMMM
> end
> 
> group = nextGroup;
> 
> if length(group) == 0
> break
> end
> 
> ```
> 
> end
> 
> return groups

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [July 4, 2022, 8:31pm UTC](https://discourse.julialang.org/t/using-graphs-to-determine-parallel-order-of-execution-for-dependencies/83757/2 "2022-07-04T20:31:22Z")

</div>

> **[GitHub - JuliaParallel/Dagger.jl: A framework for out-of-core and parallel...](https://github.com/JuliaParallel/Dagger.jl)**
>
> A framework for out-of-core and parallel execution - GitHub - JuliaParallel/Dagger.jl: A framework for out-of-core and parallel execution

Might be what you are looking for

---

<div class="post-metadata">

**Author:** ![Jon\_Barker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jon_barker/32/18997_2.png) [@Jon\_Barker](https://discourse.julialang.org/u/Jon_Barker)\
**Post date:** [July 4, 2022, 8:32pm UTC](https://discourse.julialang.org/t/using-graphs-to-determine-parallel-order-of-execution-for-dependencies/83757/3 "2022-07-04T20:32:26Z")

</div>

Thanks - ’ Directed acyclic graph’ sounds familiar when I was researching this. I’ll check out that package.
