I have a graph that is a sort of “pre-requisite” graph that I use in my class, to show my students “We need to learn [this] in order to learn [that].” I will paste the full graph at the bottom. I could instead make a more minimal example if it’s desired but I paste the complete graph in case the complexity is important for my question below.

I would like to (programmatically) “highlight” a particular path in my graph. Specifically, I would like to input the name of a node (e.g., “variance”) to the script and the script would color that node in yellow and would color all of the children nodes and edges in green. All of the other nodes and edges would be greyed out. In the particular example where I input “variance” I would want the node “variance” colored in yellow and I would want the following nodes (as well as the relevant edges) colored green: “standardization”, “confidence interval”, “inference”, “causal inference”, “standard error”, “test statistic”, “hypothesis testing”, “p-value”, “efficiency”. All other nodes would be greyed out.

I’d like to keep the position of everything the same as the original graph, in order to get the “highlight” effect, when switching slides (I’m planning to incorporate these into a beamer presentation).

I will do this often in my class, for each topic I introduce, so I would like to be able to change “variance” to the name of a different node and get a similar result. That’s why I want a scripted approach where I input the name of the node.

```
digraph econometrics {
label = "Prereq chart: it is necessary (solid lines) or helpful (dashed lines) to understand source nodes in order to understand target nodes.";
labelloc = "top";
subgraph prob {
label = "Probability"
node [color = red]
"experiment"
"random variable" -> "random interval"
"random variable" -> { "probability distribution", "i.i.d." }
"i.i.d."
"normal distribution"
"expected value"
"conditional expected value"
"variance"
"probability distribution" -> "i.i.d."
"probability distribution" -> "expected value"
"variance" -> "standardization"
"Law of Large Numbers"
"Central Limit Theorem"
}
subgraph stats {
label = "Statistics"
node [color = teal]
// used to have this in probability, but I like this here.
"sample"
"parameter"
"random interval" -> "confidence interval"
"random variable" -> "estimator"
"estimator"
"population"
"inference"
"causal effect"
"causal effect estimator"
"causal effect assumption"
"causal inference"
"regression function"
"OLS"
"error term"
"estimator" -> { "unbiasedness", "efficiency" }
"p-value"
"test statistic"
"hypothesis testing"
"story telling"
"counterfactual outcome"
"standard error"
}
"variance" -> "efficiency"
"expected value" -> "unbiasedness"
"estimator" -> "standard error"
"standard error" -> "confidence interval"
"standard error" -> "test statistic"
"expected value" -> "variance"
"expected value" -> "conditional expected value"
"conditional expected value" -> "regression function" -> "OLS"
"parameter" -> "regression function"
"error term" -> "causal effect assumption"
// TODO: currently I treat "parameter" only in statistical sense....
// this link is key and connects the worlds of probability to
// statistics
// Maybe have separate notes "parameter of a distribution" and "parameter of a population" (?).
"population" -> "parameter"
// TODO: this is for catching uncategorized nodes.
// node [color = pink]
"estimator" -> "OLS";
"sample" -> "estimator"
"parameter" -> "estimator"
// TODO: have a slide explaining this edge.
// it is about replacing sigma^2 with \hat{sigma^2}!
"estimator" -> "confidence interval"
"probability distribution" -> "normal distribution"
"normal distribution" -> "confidence interval"
"normal distribution" -> "Central Limit Theorem"
"Central Limit Theorem" -> { "hypothesis testing" , "confidence interval" }
"normal distribution" -> "standardization"
"standardization" -> { "confidence interval", "test statistic" }
"i.i.d." -> "sample"
// not strictly necessary. e.g., time series.
"i.i.d." -> "estimator" [style = dashed]
"experiment" -> "sample"
"experiment" -> "random variable"
"parameter" -> "causal effect"
"OLS" -> "causal effect estimator" [style = dashed]
"story telling" -> "causal effect assumption"
"counterfactual outcome" -> "causal effect assumption"
// causal effect is *defined* in terms of counterfactual outcomes
"counterfactual outcome" -> "causal effect"
"causal effect assumption" -> "causal effect estimator"
"causal effect" -> "causal effect estimator"
// to emphasize that a test statistic *is* a r.v.
"random variable" -> "test statistic"
// a test statistic is usually based on an estimator
// but not always.
"estimator" -> "test statistic" [style = dashed]
"parameter" -> "hypothesis testing"
"test statistic" -> "hypothesis testing"
"test statistic" -> "p-value"
"probability distribution" -> "test statistic"
"confidence interval" -> "inference"
"hypothesis testing" -> "inference"
"estimator" -> "inference"
"Central Limit Theorem"
"i.i.d." -> "Law of Large Numbers" [style = dashed]
"Law of Large Numbers" -> "estimator" [style = dashed]
"inference" -> "causal inference"
"OLS" -> "causal inference" [style = dashed]
"causal effect estimator" -> "causal inference"
"variance" -> "standard error"
}
```