Graphs
vertices and edges
The idea
A graph is points (vertices) and lines between them (edges) — a map of any kind of connections.The board
- Cities and roads, people and friendships, pages and links — it's all a graph.
- Degree of a vertex: how many edges come out of it.
- Path: a sequence of edges. Tree: a connected graph with no cycles.
- The bridges of Königsberg (Euler, 1736): you can cross every bridge exactly once only if at most 2 vertices have odd degree.
The most common mistake
Thinking the positions of the points matter. Only the connections matter.The trick
Google Maps finds the shortest path in a graph with Dijkstra's algorithm.Problems
The sum of the degrees is always…
- 2 × the number of edges
- 0
- odd
- the number of vertices
Show the answer
2 × the number of edges — Every edge is counted twice.
A tree with 10 vertices has how many edges:
- 10
- 9
- 11
- 45
Show the answer
9 — Always n − 1.