String returns a text representation of a graph, for debugging purposes.
()
| 724 | |
| 725 | // String returns a text representation of a graph, for debugging purposes. |
| 726 | func (g *Graph) String() string { |
| 727 | var s []string |
| 728 | |
| 729 | nodeIndex := make(map[*Node]int, len(g.Nodes)) |
| 730 | |
| 731 | for i, n := range g.Nodes { |
| 732 | nodeIndex[n] = i + 1 |
| 733 | } |
| 734 | |
| 735 | for i, n := range g.Nodes { |
| 736 | name := n.Info.PrintableName() |
| 737 | var in, out []int |
| 738 | |
| 739 | for _, from := range n.In { |
| 740 | in = append(in, nodeIndex[from.Src]) |
| 741 | } |
| 742 | for _, to := range n.Out { |
| 743 | out = append(out, nodeIndex[to.Dest]) |
| 744 | } |
| 745 | s = append(s, fmt.Sprintf("%d: %s[flat=%d cum=%d] %x -> %v ", i+1, name, n.Flat, n.Cum, in, out)) |
| 746 | } |
| 747 | return strings.Join(s, "\n") |
| 748 | } |
| 749 | |
| 750 | // DiscardLowFrequencyNodes returns a set of the nodes at or over a |
| 751 | // specific cum value cutoff. |
nothing calls this directly
no test coverage detected