Hello! There is a graph in which the nodes are words (type Word ), and the edges are substitutions that turn one word into another.
For example: between nodes 123 and 333 there is an edge 12->33 .
There is a method that searches all the paths from one word to another and stores them in this.Path :
func (this *Graph) FindPath(from Word, to Word, visited Dict, current Path) { if from.Eq(to) { if len(this.Pathes) == 0 { fmt.Println(current) } this.Pathes = append(this.Pathes, current) return } if visited.Index(from) != -1 { // если уже были в этом узле return } index := this.nodes.Index(from) if index == -1 { return } for r := 0; r < len(this.rules); r++ { index := from.Index(this.rules[r].Pat) if index == -1 { continue } this.FindPath(from.ApplyRule(this.rules[r]), to, append(visited, from), append(current, this.rules[r])) } return } After this method finishes, this.Path will have both the right and the wrong ways. Add this line to main :
fmt.Println(g.Pathes[0]) and compare with the output of 4 lines of the FindPath method. We get:
[{[1 0 1] [0]} {[0] [1]} {[1] [1 0]} {[1 0] [1 1]}] // FindPath, правильный путь [{[1 0 1] [0]} {[0] [1]} {[1] [1 0]} {[1 0] [1 1 1]}] // main Could you help me? I can post more code, but it seems to me that the error is here.