graphFrom returns a graph representing the point path p.
(p path)
| 573 | |
| 574 | // graphFrom returns a graph representing the point path p. |
| 575 | func graphFrom(p path) graph { |
| 576 | g := make([]set, len(p)) |
| 577 | seen := make(map[point]int) |
| 578 | for i, v := range p { |
| 579 | if _, ok := seen[v]; !ok { |
| 580 | seen[v] = i |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | for i, v := range p { |
| 585 | e, ok := seen[v] |
| 586 | if ok && g[e] == nil { |
| 587 | g[e] = make(set) |
| 588 | } |
| 589 | if i < len(p)-1 { |
| 590 | g[e][seen[p[i+1]]] = struct{}{} |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | return g |
| 595 | } |
| 596 | |
| 597 | // subpath returns a subpath given the slice of point indices |
| 598 | // into the path. |
no outgoing calls
searching dependent graphs…