circuit is the CIRCUIT sub-procedure in the paper.
(v int)
| 70 | |
| 71 | // circuit is the CIRCUIT sub-procedure in the paper. |
| 72 | func (j *johnson) circuit(v int) bool { |
| 73 | f := false |
| 74 | j.stack = append(j.stack, v) |
| 75 | j.blocked[v] = true |
| 76 | |
| 77 | //L1: |
| 78 | for w := range j.adjacent[v] { |
| 79 | if w == j.s { |
| 80 | // Output circuit composed of stack followed by s. |
| 81 | r := make([]int, len(j.stack)+1) |
| 82 | copy(r, j.stack) |
| 83 | r[len(r)-1] = j.s |
| 84 | j.result = append(j.result, r) |
| 85 | f = true |
| 86 | } else if !j.blocked[w] { |
| 87 | if j.circuit(w) { |
| 88 | f = true |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | //L2: |
| 94 | if f { |
| 95 | j.unblock(v) |
| 96 | } else { |
| 97 | for w := range j.adjacent[v] { |
| 98 | j.b[w][v] = struct{}{} |
| 99 | } |
| 100 | } |
| 101 | j.stack = j.stack[:len(j.stack)-1] |
| 102 | |
| 103 | return f |
| 104 | } |
| 105 | |
| 106 | // unblock is the UNBLOCK sub-procedure in the paper. |
| 107 | func (j *johnson) unblock(u int) { |