MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / fillOrder

Method fillOrder

graph/kosaraju.go:50–61  ·  view source on GitHub ↗

Helper function to fill the stack with vertices in the order of their finish times.

(v int, visited []bool, stack *[]int)

Source from the content-addressed store, hash-verified

48
49// Helper function to fill the stack with vertices in the order of their finish times.
50func (g *Graph) fillOrder(v int, visited []bool, stack *[]int) {
51 visited[v] = true
52
53 for neighbor := range g.edges[v] {
54 if !visited[neighbor] {
55 g.fillOrder(neighbor, visited, stack)
56 }
57 }
58
59 // Push the current vertex to the stack after exploring all neighbors.
60 *stack = append(*stack, v)
61}
62
63// Helper function to create a transposed (reversed) graph.
64func (g *Graph) transpose() *Graph {

Callers 1

KosarajuMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected