A graph is a set of vertices (nodes) together with a set of edges joining pairs of them. Almost any relation can be modelled as one — the skill is noticing when a problem is a graph problem.
- Order: · Size:
- Degree — number of incident edges; split into in-degree and out-degree when directed.
Edges may be undirected or directed, weighted or unweighted.
Taxonomy
| Category | Type | Definition |
|---|---|---|
| Direction | Undirected | implies |
| Directed (digraph) | every edge is one-way | |
| Weights | Unweighted | every edge costs 1 |
| Weighted | each edge carries a cost, length or capacity | |
| Edge rules | Simple | no self-loops, no parallel edges |
| Multigraph | parallel edges allowed | |
| Pseudograph | self-loops and parallel edges allowed | |
| Connectivity | Connected | every pair has a path between them |
| Disconnected | some pair has none | |
| Component | a maximal connected subgraph | |
| Structure | Complete | every pair joined by exactly one edge |
| Regular | every vertex has the same degree | |
| Bipartite | vertices split into two sets, every edge crosses | |
| Cycles | Cyclic / Acyclic | contains a cycle, or does not |
| Tree | connected, undirected, acyclic | |
| Forest | acyclic, possibly disconnected | |
| Rooting | Out-tree (arborescence) | rooted, all edges point away from the root |
| In-tree (anti-arborescence) | rooted, all edges point toward the root |
Special named graphs
- DAG — directed, no directed cycle. A topological ordering exists. Every finite DAG has at least one source and one sink.
- Complete bipartite — every vertex of one side joined to every vertex of the other; edges.
- Path graph — a single simple path; two vertices of degree 1, the rest degree 2.
- Star — one centre of degree , all others leaves.
- Wheel — a cycle plus a centre adjacent to every cycle vertex.
- Hypercube — vertices are -bit strings, adjacent when they differ in one bit. vertices, edges, -regular.
- Tournament — an orientation of a complete graph; exactly one directed edge per pair. A transitive tournament is a DAG.
- Complement — same vertices, adjacency inverted.
- Line graph — one vertex per edge of ; adjacent when the edges share an endpoint.
- Caterpillar — a tree that becomes a path once all leaves are removed.
- Chordal — every cycle of length has a chord. Includes trees and complete graphs.
- Planar — drawable with no crossings; and .
- Eulerian — has a closed walk using every edge once; connected with all degrees even. See Eulerian Paths.
- Semi-Eulerian — has an Eulerian path; exactly two odd-degree vertices.
- Hamiltonian — has a cycle visiting every vertex once. No usable characterisation is known — deciding it is NP-complete.
- Semi-Hamiltonian — has a Hamiltonian path but perhaps no cycle.
Terminology
| Term | Meaning |
|---|---|
| Adjacent vertices | joined by an edge |
| Incident edge | an edge touching a given vertex |
| Path | a sequence of vertices with consecutive ones adjacent |
| Path length | number of edges in the path |
| Simple path | no repeated vertex |
| Cycle | a path returning to its start with no repeated interior vertex |
| Leaf / pendant | degree 1 |
| Isolated vertex | degree 0 |
| Bridge (cut edge) | removing it increases the component count |
| Articulation point (cut vertex) | removing it increases the component count |
| Subgraph | a subset of vertices and edges |
| Spanning subgraph | contains all vertices |
| Spanning tree | a spanning subgraph that is a tree |
Theorems worth memorising
| Result | Statement |
|---|---|
| Handshake lemma | — the degree sum is always even, so the number of odd-degree vertices is even |
| Bipartite characterisation | is bipartite iff it has no odd cycle |
| Tree characterisation | connected and exactly edges (any two of: connected, acyclic, edges, implies the third) |
| Forest edge count | a forest with components has edges |
| Complete graph edges | |
| Max edges, simple undirected | |
| Max edges, simple directed | |
| Planar edge bound | for ; if triangle-free |
| Euler’s formula | for a connected planar graph |
See also: Representations · Graph Theory