Skip to content

Commit

Permalink
dag: make vertex children a map instead of a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGamba committed Oct 16, 2024
1 parent 8345be4 commit a43128f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type (
ID ID
Task *Task
Retries int
Children []*Vertex
Children map[ID]*Vertex
Parents []*Vertex
status runStatus
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func (g *Graph) addTask(t *Task) error {
g.Vertices[t.ID] = &Vertex{
ID: t.ID,
Task: t,
Children: make([]*Vertex, 0),
Children: make(map[ID]*Vertex),
Parents: make([]*Vertex, 0),
status: runPending,
}
Expand Down Expand Up @@ -373,7 +373,7 @@ func (g *Graph) TaskDependsOn(t *Task, tDependencies ...*Task) {
}
}
g.dotDiagram += fmt.Sprintf("\t\"%s\" -> \"%s\";\n", vertex.ID, vDependency.ID)
vertex.Children = append(vertex.Children, vDependency)
vertex.Children[vDependency.ID] = vDependency
vDependency.Parents = append(vDependency.Parents, vertex)
}
}
Expand Down
1 change: 0 additions & 1 deletion dag/dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func TestDagSorted(t *testing.T) {

g := NewGraph("test graph")
g.Ordered = true
// g.SetSerial()
g.TaskDependsOn(tm.Get("t1"), tm.Get("t2"), tm.Get("t3"))
g.TaskDependsOn(tm.Get("t2"), tm.Get("t4"))
g.TaskDependsOn(tm.Get("t3"), tm.Get("t4"))
Expand Down

0 comments on commit a43128f

Please sign in to comment.