entropyScore computes a score for a node representing how important it is to include this node on a graph visualization. It is used to sort the nodes and select which ones to display if we have more nodes than desired in the graph. This number is computed by looking at the flat and cum weights of th
(n *Node)
| 1073 | // edges. The fundamental idea is to penalize nodes that have a simple |
| 1074 | // fallthrough from their incoming to the outgoing edge. |
| 1075 | func entropyScore(n *Node) int64 { |
| 1076 | score := float64(0) |
| 1077 | |
| 1078 | if len(n.In) == 0 { |
| 1079 | score++ // Favor entry nodes |
| 1080 | } else { |
| 1081 | score += edgeEntropyScore(n, n.In, 0) |
| 1082 | } |
| 1083 | |
| 1084 | if len(n.Out) == 0 { |
| 1085 | score++ // Favor leaf nodes |
| 1086 | } else { |
| 1087 | score += edgeEntropyScore(n, n.Out, n.Flat) |
| 1088 | } |
| 1089 | |
| 1090 | return int64(score*float64(n.Cum)) + n.Flat |
| 1091 | } |
| 1092 | |
| 1093 | // edgeEntropyScore computes the entropy value for a set of edges |
| 1094 | // coming in or out of a node. Entropy (as defined in information |
no test coverage detected
searching dependent graphs…