This solution is neat! Essentially, it suggests intermediate computations can add new events, and as long as they're described in a way that subsequent ones can skip them while still giving the appropriate end result, it's good.
This sounds right for this particular scenario, but as is, doesn't seem generally applicable. I'll keep marked unanswered in case the general scenario can get solved, but as is, awesome. Thank you!
Edit: here's the corresponding macro
degree(src,dst,node,in,out,degree)
appendpipe [
stats count($src$) as $in$ by $dst$
| rename $dst$ as $node$]
| appendpipe [
stats count($dst$) as $out$ by $src$
| rename $src$ as $node$]
| stats max(*) as * by $node$
| fillnull $in$ $out$
| eval $degree$=$in$+$out$
... View more