{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $G$ be a [[graph|0JD5C82QMB]] and let $u, v$ be vertices of $G$.\nIf $v$ is [[reachable|0J8XE7W68F]] from $u$, the distance $d(u, v)$ is the smallest length of a [[walk|0VJZM0F9YM]] from $u$ to $v$.\nIf $v$ is not reachable from $u$, then $d(u, v) = \\infty$.\n\n## Remarks\n\nA shortest walk is a [[path|0JDE56HWQ8]], so $d(u, v)$ is also the smallest length of a path. Such a path is a geodesic.\nOn a [[connected|0FFAYNMAJZ]] graph, $d$ is a metric: $d(u, v) = 0$ only for $u = v$, it is symmetric, and it satisfies the triangle inequality.\n\n## Explanations\n\n### L1 human\n\nThe distance between two vertices is the smallest number of edges that you must cross to go from one to the other.\nIn the cycle $C_6$, opposite vertices have distance $3$.\n",
  "commit": "f591989ed15704e9d8755a7a5a6426d73de7a3ae",
  "front": {
    "defines": "0QV9VNNB4Z",
    "kind": "definition",
    "msc": [
      "05C12"
    ],
    "name": "Distance in a graph",
    "sources": [
      {
        "locator": "lead section",
        "url": "https://en.wikipedia.org/wiki/Distance_(graph_theory)"
      }
    ],
    "tag": "0WPZ5YPAGR",
    "uses": [
      "0VJZM0F9YM",
      "0J8XE7W68F"
    ]
  },
  "kind": "definition",
  "link": "https://math2.tamnd.com/node/0WPZ5YPAGR/",
  "links": [
    {
      "field": "defines",
      "target": "0QV9VNNB4Z"
    },
    {
      "field": "uses",
      "target": "0VJZM0F9YM"
    },
    {
      "field": "uses",
      "target": "0J8XE7W68F"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/0WPZ5YPAGR.md",
  "msc": [
    "05C12"
  ],
  "name": "Distance in a graph",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/0WP/0WPZ5YPAGR.md",
  "status": null,
  "tag": "0WPZ5YPAGR",
  "uri": "m2://0WPZ5YPAGR",
  "url": "https://math2.tamnd.com/wiki/distance-in-a-graph-definition/",
  "writing": {
    "tag": "0WPZ5YPAGR",
    "kind": "definition",
    "level": "W1",
    "next": [
      {
        "what": "edge instance_of in",
        "note": "one example",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge not_instance_of in",
        "note": "one non-example that fails one clause",
        "have": 0,
        "want": 1
      }
    ]
  }
}
