Graphs and Basic Definitions
How many handshakes happen at a party? Can you tell who shook hands with whom just from a diagram of dots and lines? This simple question is the seed of graph theory. It is a branch of discrete mathematics that models pairwise relationships between objects. A graph strips away all irrelevant detail — geography, color, size. It keeps only the abstract pattern of connection. This radical simplification is exactly why graphs are so useful. The same formal structure describes road networks, molecules, social ties, computer circuits, and scheduling conflicts. The power of graph theory comes from separating two things that are easy to conflate. One is the combinatorial data of a graph (which pairs of objects are related). The other is the picture we draw of it (dots and curves in the plane). Two very differently drawn pictures can represent the same graph. One picture can also obscure structure that a careful definition reveals instantly. Building a rigorous foundation lets us state and prove theorems clearly. This means precise definitions of vertices, edges, adjacency, and incidence. These theorems hold no matter how the graph is drawn. This article develops that foundation from scratch, assuming only basic set theory. We define simple graphs first, since they are the cleanest setting. Then we generalize to multigraphs and graphs with loops. These are needed to model repeated connections, like multiple flights between two cities. They also model self-relations, like a webpage linking to itself. We are careful throughout to distinguish a graph as a mathematical object. It is an ordered pair of sets with a structure connecting them. This is different from any particular drawing of it. By the end, you will have precise vocabulary for several key concepts. These include vertices, edges, endpoints, adjacency, incidence, and degree. You will also know the various flavors of graph. These are simple, multigraph, with or without loops. Together with these, you will meet a first non-trivial theorem. It is a lemma bounding the number of edges in a simple graph. This groundwork is the launching point for everything that follows in graph theory. That includes the Handshake Lemma, the notion of Graph Isomorphism, and the study of Subgraphs and Special Graph Families.
- A graph is a pair : a set of vertices and a set (or multiset) of edges connecting pairs of vertices.
- In a simple graph, edges are unordered pairs of distinct vertices, with no repeats and no self-loops.
- Adjacency relates two vertices joined by an edge; incidence relates a vertex to an edge that has it as an endpoint.
- Multigraphs allow repeated edges between the same pair of vertices; graphs with loops allow an edge from a vertex to itself.
- A graph is combinatorial data, not a picture — the same graph can be drawn in infinitely many ways.
- Key idea: a graph is nothing more than a set of objects together with a specified collection of pairs among them, and everything else (drawings, degrees, paths) is built rigorously on top of that one idea.
Where this lives today
Graphs, in the precise sense defined here, are the substrate for an enormous range of applications. In computer science, graphs model computer networks (vertices = machines, edges = links), the World Wide Web (vertices = pages, edges = hyperlinks — naturally directed and possibly with loops, since pages can link to themselves), and dependency structures in compilers and build systems. In operations research and engineering, graphs represent transportation and logistics networks, where multigraphs are essential because multiple distinct routes between the same two locations are common, exactly as in the worked bus-route example above. In chemistry, molecular structure diagrams are graphs whose vertices are atoms and whose edges are bonds; double and triple bonds are naturally modeled with parallel edges (a multigraph). In social science and epidemiology, graphs model acquaintance and contact networks, with adjacency encoding a direct relationship (friendship, contact) that then feeds into models of information spread or disease transmission. In cryptography and complexity theory, hardness of certain graph problems (like finding large cliques, related to the complete-graph notion introduced above) underlies security assumptions and complexity-class separations. In statistics and machine learning, graphical models encode conditional independence structure among random variables using vertices for variables and edges for direct dependencies. All of these applications depend on the basic distinctions made rigorous here: what counts as a vertex versus an edge, whether loops or parallel edges are permitted, and the sharp separation between a graph's combinatorial identity and any particular drawing of it — distinctions that become indispensable once one studies Degree and the Handshake Lemma and, later, Graph Isomorphism.
Ask the tutor: Can you walk through how the definition of a graph changes once we allow edges to be directed, and how adjacency then splits into "in-neighbor" and "out-neighbor"?
A simple graph is an ordered pair where:
- is a finite set, called the vertex set, whose elements are called vertices;
- is a set of 2-element subsets of , called the edge set, whose elements are called edges.
If is an edge, we say and are its endpoints, that and are adjacent (or neighbors), and that is incident to and to . Two edges that share exactly one endpoint are called adjacent edges. A multigraph is a triple where is a finite vertex set, is a finite set of edge labels, and
assigns to each edge label either a -element subset (an ordinary edge with endpoints ) or a single vertex (a loop at , whose only "endpoint" is , counted twice). Here denotes the set of -element subsets of .
- If is injective and never takes a single-vertex value (no loops), the multigraph is exactly a simple graph in the sense above (up to renaming edges by their image).
- If is not injective, distinct edge labels with are called parallel edges (or multi-edges).
- A loop is an edge with for a single vertex ; by convention a loop contributes to the degree of (see below), consistent with it having "two coincident endpoints."
For a vertex , the degree is the number of edge-endpoint incidences at : in a simple graph, ; in a multigraph, , i.e. each ordinary incidence counts once and each loop at counts twice. Throughout, unless stated otherwise, "graph" means simple graph: no loops, no parallel edges, edges unordered.
Intuition
Think of a graph as the abstract skeleton of a network. The vertices are the "things" — people, cities, atoms, web pages — and the edges record which pairs of things are directly related. Crucially, a graph carries no information about position, distance, or order beyond the bare adjacency data: if you redraw the dots anywhere in the plane and redraw the connecting curves anywhere between them, as long as the same pairs of dots are joined, it is the same graph. This is why we insist on the set-theoretic definition rather than a picture. A picture is a witness, or a convenient encoding, but the mathematical object is the pair . For instance the vertex set with edge set is a 4-cycle no matter whether you draw it as a square, a bowtie-looking self-crossing shape, or a wobbly quadrilateral — the combinatorics is identical. Adjacency is symmetric ( adjacent to iff adjacent to , since as sets) and it is a relation between vertices, while incidence is a relation between a vertex and an edge. Keeping these two words distinct avoids a huge amount of confusion later, especially once directed graphs and hypergraphs enter the picture. The step from simple graphs to multigraphs (allowing parallel edges) and graphs with loops is motivated by real modeling needs: two cities might be joined by several distinct flight routes (parallel edges), and a web page might link to itself (a loop). The formal device — an auxiliary function from a set of edge names to the set of vertex pairs (or single vertices) — is what lets us have two different edges "look the same" as a pair while remaining genuinely distinct objects of the edge set .
Let be a simple graph with vertices. Then
and the upper bound is attained if and only if is the complete graph , i.e. every pair of distinct vertices is adjacent.
Setup. By definition, is a set of -element subsets of , i.e. , where denotes the collection of all -element subsets of .
Lower bound. Since is a set, trivially (cardinality of any set is nonnegative), with equality exactly when , i.e. has no edges at all. This case is realizable (take any and ), so the lower bound is tight.
Upper bound, via counting. We compute directly. A -element subset of is determined by an unordered choice of distinct elements from the -element set . We count ordered pairs of distinct elements first: there are choices for the first coordinate and remaining choices for the second, giving ordered pairs with . Each unordered pair with corresponds to exactly ordered pairs, namely and , and this correspondence is a bijection between ordered pairs and (unordered pair, ordering) data. Hence the number of unordered pairs is
This is a special case of the standard combinatorial identity for counting -subsets, applied here with ; we have re-derived it directly rather than citing it as a black box, to keep the proof self-contained.
Monotonicity of cardinality under subset inclusion. Since and both are finite sets, the basic set-theoretic fact " for finite sets" (immediate from the definition of cardinality: an injection is given by the inclusion map, and for finite sets injections cannot increase cardinality) yields
This proves the upper bound.
Characterization of equality. Suppose . Since and both sets are finite with equal cardinality, (a subset of a finite set with the same cardinality as the whole set must equal the whole set — otherwise there would exist an element of , and then , a contradiction). So means every -element subset of is an edge, i.e. every pair of distinct vertices is adjacent — precisely the definition of being the complete graph on vertex set . Conversely, if , then by definition , so by the computation above. This establishes both bounds and the equality characterization, completing the proof.
∎For a fixed finite vertex set with , there are exactly possible edges, hence exactly distinct simple graphs on vertex set (each subset of is a valid edge set).
Proof of corollary. Immediate from the theorem's counting argument: ranges freely over all subsets of the -element set , and a finite set with elements has exactly subsets (each of the elements is independently included or excluded).
Worked examples
Example 1 — a graph modeling a genuinely asymmetric situation. Consider a small collaboration network among five researchers, labeled by their initials:
Suppose the co-authorship data is: has written with and with ; has written with , with , and with ; has written with and with ; has written with and with ; has written with only. Encoding "has written with" as an edge, we get
Note . Let us verify this is consistent and extract basic data. Degrees. Count incidences at each vertex:
- : appears in and , so .
- : appears in , so .
- : appears in , so .
- : appears in , so .
- : appears only in , so .
Sum of degrees: , consistent with the fact (foreshadowing the Handshake Lemma) that the sum of all degrees always equals twice the number of edges, since each edge contributes exactly to the degree of each of its two distinct endpoints. Checking the bound of the theorem. Here , so . Indeed , consistent with the theorem, and is far from complete: e.g. ( and never co-authored), , . Precisely pairs are non-edges, matching . Adjacency vs. incidence, made concrete. and are adjacent (joined by the edge ). The edge is incident to and incident to ; it is not incident to , , or . The edges and are adjacent edges, since they share the single endpoint ; the edges and are not adjacent, since they share no endpoint.
Example 2 — a multigraph with a loop, showing where the extra structure is needed. A small city has bus routes connecting four terminals . Route data: there are two distinct express routes both running nonstop between and (different companies, same two terminals); there is one route between and ; there is a circular sightseeing tour that departs from and returns to without stopping elsewhere (a loop at ); and there is one route between and . Vertex additionally has no route to or to directly. This cannot be modeled as a simple graph, because a simple graph's edge set is a set of pairs, so it cannot record "two distinct routes between the same pair of terminals," nor can with ever occur (a simple graph's edges are -element subsets, which by definition have two distinct elements). We use the multigraph definition instead. Let the edge-label set be
with assignment function given by
Here are parallel edges, since but they are different elements of (different bus companies). is a loop at , since is a single vertex. Degree computation, carefully. Using the multigraph degree definition (ordinary incidences count once, loops count twice):
- : is an endpoint of and (each ordinary), so .
- : is an endpoint of , so .
- : is an endpoint of (ordinary, contributes ), (loop, contributes ), and (ordinary, contributes ); so .
- : is an endpoint of only, so .
Sum of degrees: . This again matches the handshake-style identity, provided loops are counted with weight — which is exactly why the convention is set up that way: it preserves "sum of degrees twice the number of edges" even in the presence of loops and parallel edges. If we had (incorrectly) counted the loop with weight , we would get degree sum , breaking the identity — a good sanity check for why the weight- convention for loops is the "correct" one, not an arbitrary choice.
The theorem above relies on the hypothesis that is a simple graph, in particular that every edge is a -element subset of with two distinct vertices — no loops, no repeats. Drop only the "no loops, no repeats" hypothesis (i.e. work with a general multigraph-with-loops instead) and the clean bound fails outright. Take (so , and ). Build a multigraph with edge-label set and
i.e. two parallel edges between and , plus a loop at each vertex. Here , while . So
directly violating the upper bound from the theorem. The proof's key step — ", hence " — used the fact that in a simple graph, distinct edges correspond to distinct elements of and every edge is an element of . Once parallel edges and loops are allowed, is no longer a subset of at all (it is only mapped into by , and that map need not be injective), so the subset-cardinality argument simply does not apply. This shows the "simple graph" hypothesis is not a technicality: it is exactly what the counting proof needs.
Scope, edge cases & common traps
| Situation | What happens | Why |
|---|---|---|
| The unique graph is (the null graph) | With no vertices there are no possible pairs, so must be | |
| , | Valid simple graph, sometimes called edgeless or empty graph on vertices | Definition only requires ; the empty subset is allowed |
| requested as an edge in a simple graph | Not allowed; is required to be a -element set | By definition a -element subset has two distinct elements |
| Two vertices connected "twice" | Not expressible in a simple graph; requires a multigraph | in a simple graph is a set, so it cannot contain the same pair twice |
| Self-loop needed | Not expressible without the extended (loop-permitting) definition | A loop's endpoints coincide, violating "-element subset" |
| Counting non-edges | gives the number of non-adjacent pairs | Direct consequence of and the edge-bound theorem |
| Confusing adjacency and incidence | A frequent notational slip in early graph theory work | Adjacency relates vertex–vertex; incidence relates vertex–edge; they are different arities |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Leonhard Euler was a Swiss mathematician whose staggering output touched nearly every branch of mathematics and physics known in his era, from number theory and analysis to mechanics and optics. He spent his working life largely at the Imperial Academy of Sciences in St. Petersburg and the Prussian Academy in Berlin, continuing to produce major results even after losing most of his eyesight later in life. His 1736 resolution of the Seven Bridges of Königsberg problem is now recognized as the founding act of graph theory: he modeled the four landmasses of Königsberg as abstract points and the seven bridges as abstract connections, discarding all geometric detail about actual bridge lengths or landmass shapes. This act of abstraction — replacing a physical map with a set of points and a set of connections between them — is precisely the conceptual move that the modern definition of a graph formalizes.
Is a graph the same thing as a picture with dots and lines?
No. A graph is the ordered pair (or the triple for multigraphs) — purely set-theoretic data specifying which pairs of vertices are joined. A drawing, or diagram, is one way of visualizing that data by placing dots for vertices and curves for edges, but the same graph admits infinitely many different drawings (different vertex positions, different curve shapes, even crossing versus non-crossing layouts). Two drawings represent the same graph exactly when they encode the same vertex set and the same edge set (up to relabeling, this is the notion of Graph Isomorphism). Keeping the distinction sharp prevents errors like thinking a graph "changes" because it was redrawn, or that geometric properties of a specific picture (like edge crossings) are inherent graph properties, when in fact they depend on the chosen drawing.
Why must edges in a simple graph be sets rather than ordered pairs?
Because in an (undirected) simple graph, the relation "is adjacent to" is symmetric: if is adjacent to , then is adjacent to , and there is no meaningful "direction" to the connection. Using unordered pairs builds this symmetry into the definition automatically, since as sets. If you used ordered pairs instead, you would be defining a directed graph (digraph), where need not imply — a genuinely different and useful structure, but not the one this article treats. The unordered-pair convention is precisely what makes "adjacency" a well-defined, direction-free relation on .
Can a graph have zero vertices, or zero edges?
Yes to both, and they are different situations. The null graph has ; since there are no vertices, too, forcing — it is the unique graph on no vertices. An edgeless graph (sometimes called an empty graph) has but ; every vertex has degree , and no two vertices are adjacent. Both are legitimate simple graphs under the definition, since the only requirement is , and the empty set is always a valid subset. These edge cases are useful base cases in inductive proofs about graphs.
What exactly is the difference between a multigraph and a simple graph, formally?
A simple graph's edge set is literally a subset of : each edge is a -element set of vertices, and since is a set, no two "edges" can be the same pair (sets don't have repeated elements). A multigraph instead has an abstract set of edge labels together with a function sending each label to a pair of vertices (or a single vertex, for a loop); need not be injective, so multiple distinct labels can map to the same pair, modeling parallel edges. Every simple graph is a multigraph in which happens to be injective and avoids loops, so multigraphs strictly generalize simple graphs, not the other way around.
Does the order of vertices in an edge {u, v} matter?
No. Because an edge in a simple graph is defined as a -element set , and sets have no internal order, and denote exactly the same edge. This is what makes the resulting adjacency relation symmetric without any extra assumption: " adjacent to " and " adjacent to " are literally the same statement, both meaning . If order mattered, we would be in the setting of directed graphs, where the ordered pair and are generally different edges representing different directions of a relationship.
Why does the theorem's proof bother re-deriving instead of just citing it?
Because rigor at the foundational level means not assuming machinery that itself needs justification, especially when that machinery (binomial coefficients) is often introduced via graph-adjacent counting arguments. Re-deriving the count of -element subsets directly from first principles — counting ordered pairs and dividing by the size of each equivalence class of orderings — keeps the proof self-contained and shows explicitly why dividing by is valid (each unordered pair corresponds to exactly orderings). This habit of justifying every step, rather than citing formulas as black boxes, is exactly the discipline the rest of graph theory depends on, starting with the very next result, the Handshake Lemma.
If loops and parallel edges are so useful, why do most introductory theorems assume simple graphs?
Because simple graphs are the cleanest setting in which to build up the basic theory, and results proved there generalize to multigraphs later with clearly-tracked extra bookkeeping (as the loop-degree convention in this article illustrates). Restricting to simple graphs first lets definitions like adjacency, degree, and edge-counting bounds be stated and proved with minimal notational overhead — there's no need to worry about an injective labeling function or about weighting loops specially. Once these ideas are solid, generalizing to multigraphs (as in the bus-route example) is mostly a matter of re-deriving analogous statements with the extra structure made explicit, rather than rethinking the theory from scratch.