{
  "format": 3,
  "id": "gcd",
  "title": "Euclid's greatest common divisor",
  "direction": "down",
  "layers": {
    "process": {
      "label": "Process"
    }
  },
  "lanes": {},
  "frames": {},
  "nodes": {
    "input": {
      "label": "Input a, b",
      "layer": "process",
      "box": [
        29.25,
        16,
        84,
        36
      ]
    },
    "test": {
      "label": "b = 0?",
      "layer": "process",
      "box": [
        38.75,
        192.6,
        65,
        36
      ]
    },
    "remainder": {
      "label": "r = a mod b",
      "layer": "process",
      "box": [
        198.926,
        369.20000000000005,
        99,
        36
      ]
    },
    "update": {
      "label": "a ← b, b ← r",
      "layer": "process",
      "box": [
        131.926,
        545.8000000000001,
        102,
        36
      ]
    },
    "result": {
      "label": "Return a",
      "layer": "process",
      "box": [
        16,
        369.20000000000005,
        78,
        36
      ]
    }
  },
  "edges": {
    "input": {
      "from": "input",
      "to": "test",
      "label": {
        "at": [
          37.64500000000001,
          126.5
        ],
        "text": "Start"
      },
      "path": "M71.25,52 L71.25,192.6",
      "badge": [
        71.25,
        139.875
      ]
    },
    "no": {
      "from": "test",
      "to": "remainder",
      "label": {
        "at": [
          233.784,
          303.1
        ],
        "text": "No"
      },
      "path": "M87.5,228.6 L87.5,238.6 L248.426,238.6 L248.426,369.20000000000005",
      "badge": [
        228.26300000000003,
        238.6
      ]
    },
    "assign": {
      "from": "remainder",
      "to": "update",
      "label": {
        "at": [
          251.42600000000002,
          479.70000000000005
        ],
        "text": "Assign"
      },
      "path": "M248.426,405.20000000000005 L248.426,491.80000000000007 L199.926,491.80000000000007 L199.926,545.8000000000001",
      "badge": [
        240.476,
        491.80000000000007
      ]
    },
    "loop": {
      "from": "update",
      "to": "test",
      "label": {
        "at": [
          126,
          391.40000000000003
        ],
        "text": "Repeat"
      },
      "path": "M165.926,545.8000000000001 L165.926,248.6 L71.25,248.6 L71.25,228.6",
      "badge": [
        165.926,
        339.8620000000001
      ]
    },
    "yes": {
      "from": "test",
      "to": "result",
      "label": {
        "at": [
          34.037000000000006,
          303.1
        ],
        "text": "Yes"
      },
      "path": "M55,228.6 L55,369.20000000000005",
      "badge": [
        55,
        316.475
      ]
    }
  },
  "scenarios": [
    {
      "id": "gcd-48-18",
      "label": "gcd(48, 18)",
      "display": {
        "counterLabel": true,
        "edges": "progressive",
        "edgeBadges": true,
        "nodeBadges": false,
        "log": "cumulative"
      },
      "steps": [
        {
          "id": "input",
          "title": "Read the input",
          "text": "a = 48, b = 18.",
          "show": [
            "input",
            "test"
          ],
          "current": [
            "test"
          ],
          "edges": [
            "input"
          ],
          "defs": [],
          "sources": [],
          "deeper": []
        },
        {
          "id": "turn-1",
          "title": "Loop 1",
          "text": "48 mod 18 = 12. Assign a = 18, b = 12; check b again.",
          "show": [
            "remainder",
            "update"
          ],
          "current": [
            "test"
          ],
          "edges": [
            "no",
            "assign",
            "loop"
          ],
          "defs": [],
          "log": [
            "48 mod 18 = 12",
            "a = 18, b = 12"
          ],
          "sources": [],
          "deeper": []
        },
        {
          "id": "turn-2",
          "title": "Loop 2",
          "text": "18 mod 12 = 6. Assign a = 12, b = 6; check b again.",
          "show": [
            "remainder",
            "update"
          ],
          "current": [
            "test"
          ],
          "edges": [
            "no",
            "assign",
            "loop"
          ],
          "defs": [],
          "log": [
            "18 mod 12 = 6",
            "a = 12, b = 6"
          ],
          "sources": [],
          "deeper": []
        },
        {
          "id": "turn-3",
          "title": "Loop 3",
          "text": "12 mod 6 = 0. Assign a = 6, b = 0; check b again.",
          "show": [
            "remainder",
            "update"
          ],
          "current": [
            "test"
          ],
          "edges": [
            "no",
            "assign",
            "loop"
          ],
          "defs": [],
          "log": [
            "12 mod 6 = 0",
            "a = 6, b = 0"
          ],
          "sources": [],
          "deeper": []
        },
        {
          "id": "result",
          "title": "Return the result",
          "text": "b = 0, so return a = 6.",
          "show": [
            "result"
          ],
          "current": [
            "result"
          ],
          "edges": [
            "yes"
          ],
          "defs": [],
          "log": [
            "gcd(48, 18) = 6"
          ],
          "sources": [],
          "deeper": []
        }
      ],
      "flow": [
        {
          "node": "input",
          "step": "input",
          "log": [
            "a = 48, b = 18"
          ]
        },
        {
          "node": "test",
          "step": "input",
          "log": [],
          "edge": "input"
        },
        {
          "node": "remainder",
          "step": "turn-1",
          "log": [
            "48 mod 18 = 12"
          ],
          "edge": "no"
        },
        {
          "node": "update",
          "step": "turn-1",
          "log": [
            "a = 18, b = 12"
          ],
          "edge": "assign"
        },
        {
          "node": "test",
          "step": "turn-1",
          "log": [],
          "edge": "loop"
        },
        {
          "node": "remainder",
          "step": "turn-2",
          "log": [
            "18 mod 12 = 6"
          ],
          "edge": "no"
        },
        {
          "node": "update",
          "step": "turn-2",
          "log": [
            "a = 12, b = 6"
          ],
          "edge": "assign"
        },
        {
          "node": "test",
          "step": "turn-2",
          "log": [],
          "edge": "loop"
        },
        {
          "node": "remainder",
          "step": "turn-3",
          "log": [
            "12 mod 6 = 0"
          ],
          "edge": "no"
        },
        {
          "node": "update",
          "step": "turn-3",
          "log": [
            "a = 6, b = 0"
          ],
          "edge": "assign"
        },
        {
          "node": "test",
          "step": "turn-3",
          "log": [],
          "edge": "loop"
        },
        {
          "node": "result",
          "step": "result",
          "log": [
            "gcd(48, 18) = 6"
          ],
          "edge": "yes"
        }
      ],
      "repeatBadges": [
        {
          "edge": "loop",
          "step": "turn-1",
          "at": [
            185.926,
            339.8620000000001
          ]
        },
        {
          "edge": "loop",
          "step": "turn-2",
          "at": [
            165.926,
            359.8620000000001
          ]
        },
        {
          "edge": "loop",
          "step": "turn-3",
          "at": [
            145.926,
            339.8620000000001
          ]
        }
      ]
    },
    {
      "id": "gcd-5-0",
      "label": "gcd(5, 0)",
      "display": {
        "counterLabel": true,
        "edges": "progressive",
        "edgeBadges": true,
        "nodeBadges": false,
        "log": "incremental"
      },
      "steps": [
        {
          "id": "input",
          "title": "Read the input",
          "text": "a = 5, b = 0.",
          "show": [
            "input",
            "test"
          ],
          "current": [
            "test"
          ],
          "edges": [
            "input"
          ],
          "defs": [],
          "sources": [],
          "deeper": []
        },
        {
          "id": "result",
          "title": "Skip the loop",
          "text": "b is already 0, so return a = 5.",
          "show": [
            "result"
          ],
          "current": [
            "result"
          ],
          "edges": [
            "yes"
          ],
          "defs": [],
          "log": [
            "gcd(5, 0) = 5"
          ],
          "sources": [],
          "deeper": []
        }
      ],
      "flow": [
        {
          "node": "input",
          "step": "input",
          "log": [
            "a = 5, b = 0"
          ]
        },
        {
          "node": "test",
          "step": "input",
          "log": [],
          "edge": "input"
        },
        {
          "node": "result",
          "step": "result",
          "log": [
            "gcd(5, 0) = 5"
          ],
          "edge": "yes"
        }
      ]
    }
  ],
  "definitions": {},
  "code": {},
  "concepts": [],
  "callouts": {},
  "deeper": [],
  "viewBox": [
    313.926,
    597.8000000000001
  ],
  "measurement": {
    "name": "font-table",
    "labels": {
      "input": {
        "width": 31.604999999999997,
        "height": 12.6
      },
      "no": {
        "width": 12.642,
        "height": 12.6
      },
      "assign": {
        "width": 37.925999999999995,
        "height": 12.6
      },
      "loop": {
        "width": 37.925999999999995,
        "height": 12.6
      },
      "yes": {
        "width": 18.963,
        "height": 12.6
      }
    }
  }
}
