The graph
A signal-flow graph draws a system as dots and arrows. Each dot, called a node, is a signal. Each arrow, called a branch, multiplies its signal by the gain written on it. We want one answer: T = Y/R.
A node's value is the sum of the signals arriving on its arrows. Node x₁ receives R × 1, x₂ × (−1) and Y × (−1), so x₁ = R − x₂ − Y. Arrows leaving a node copy its value; they never change it.
Paths and loops
A forward path runs from input to output, visiting no node twice. Its gain is the product of its branch gains. The main path gives P₁ = 1 × 1/s × 1 × 1/s × 1 = 1/s².
The branch R → x₃ skips ahead, so there is a second forward path: R → x₃ → x₄ → Y. Its gain is P₂ = 1 × 1/s × 1 = 1/s. Mason's rule uses every forward path.
A loop starts at a node, follows the arrows and comes back, visiting no node twice. Its gain is the product around it. L₁ = 1/s × (−1) = −1/s. L₂ = 1/s × (−2) = −2/s.
One more loop goes all the way round, through the output and back to x₁. L₃ = 1/s × 1 × 1/s × 1 × (−1) = −1/s². That makes three loops in all.
Mason's rule
Two loops touch if they share a node. L₁ uses x₁ and x₂; L₂ uses x₃ and x₄. They share nothing, so they are non-touching. L₃ touches both. The only non-touching pair is L₁L₂ = 2/s².
Δ = 1 − (sum of all loop gains) + (sum of non-touching pairs) − (non-touching triples) and so on. Here: Δ = 1 + 1/s + 2/s + 1/s² + 2/s² = 1 + 3/s + 3/s².
Δₖ is Δ worked out with only the loops that do not touch path k. P₁ touches all three loops, so Δ₁ = 1. P₂ misses L₁, so Δ₂ = 1 − L₁ = 1 + 1/s.
T = (P₁Δ₁ + P₂Δ₂)/Δ = (1/s + 2/s²)/(1 + 3/s + 3/s²). Multiply top and bottom by s²: T(s) = (s + 2)/(s² + 3s + 3). One formula, no redrawing.
Check it
Push a unit step into R. Simulating the graph node by node and simulating T(s) draw the same curve. It settles at T(0) = 2/3, the value of T(s) at s = 0.
What is happening
# step 1/11 · graph
# about: Input R, Output Y
node a signal (R, x₁ … x₄, Y)
branch an arrow with a gain:
head signal = gain × tail signal
this graph 6 nodes, 9 branches
goal T(s) = Y(s)/R(s)
The same system as a block diagram:
two lags 1/(s + 1) and 1/(s + 2) in a row,
a feedforward from R into the second,
all inside unity negative feedback.
The branch gains are illustrative round numbers, not a measured machine. Every number and curve in the figure is computed from them. The Python is plain Python 3. Each gain is a list of coefficients of 1/s, lowest power first, so [1, 3, 3] means 1 + 3/s + 3/s². Multiplying by s² turns that list into s² + 3s + 3.