edgeEntropyScore computes the entropy value for a set of edges coming in or out of a node. Entropy (as defined in information theory) refers to the amount of information encoded by the set of edges. A set of edges that have a more interesting distribution of samples gets a higher score.
(n *Node, edges EdgeMap, self int64)
| 1096 | // edges. A set of edges that have a more interesting distribution of |
| 1097 | // samples gets a higher score. |
| 1098 | func edgeEntropyScore(n *Node, edges EdgeMap, self int64) float64 { |
| 1099 | score := float64(0) |
| 1100 | total := self |
| 1101 | for _, e := range edges { |
| 1102 | if e.Weight > 0 { |
| 1103 | total += abs64(e.Weight) |
| 1104 | } |
| 1105 | } |
| 1106 | if total != 0 { |
| 1107 | for _, e := range edges { |
| 1108 | frac := float64(abs64(e.Weight)) / float64(total) |
| 1109 | score += -frac * math.Log2(frac) |
| 1110 | } |
| 1111 | if self > 0 { |
| 1112 | frac := float64(abs64(self)) / float64(total) |
| 1113 | score += -frac * math.Log2(frac) |
| 1114 | } |
| 1115 | } |
| 1116 | return score |
| 1117 | } |
| 1118 | |
| 1119 | // NodeOrder sets the ordering for a Sort operation |
| 1120 | type NodeOrder int |
no test coverage detected
searching dependent graphs…