MCPcopy Create free account
hub / github.com/google/pprof / edgeEntropyScore

Function edgeEntropyScore

internal/graph/graph.go:1098–1117  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1096// edges. A set of edges that have a more interesting distribution of
1097// samples gets a higher score.
1098func 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
1120type NodeOrder int

Callers 1

entropyScoreFunction · 0.85

Calls 1

abs64Function · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…