Graph (discrete mathematics)
Graph

A graph (sometimes called an undirected graph to distinguish it from a directed graph, or a simple graph to distinguish it from a multigraph) is a pair G = (V, E), where V is a set whose elements are called vertices (singular: vertex), and E is a set of unordered pairs { v 1, v 2 } {\displaystyle \{v_{1},v_{2}\}} of vertices, whose elements are called edges (sometimes links or lines).

The vertices u and v of an edge { u, v } are called the edge's endpoints. The edge is said to join u and v and to be incident on them. A vertex may belong to no edge, in which case it is not joined to any other vertex and is called isolated. When an edge { u, v } {\displaystyle \{u,v\}} exists, the vertices u and v are called adjacent.

A multigraph is a generalization that allows multiple edges to have the same pair of endpoints. In some texts, multigraphs are simply called graphs.

Sometimes, graphs are allowed to contain loops, which are edges that join a vertex to itself. To allow loops, the pairs of vertices in E must be allowed to have the same node twice. Such generalized graphs are called graphs with loops or simply graphs when it is clear from the context that loops are allowed.

Generally, the vertex set V is taken to be finite (which implies that the edge set E is also finite). Sometimes infinite graphs are considered, but they are usually viewed as a special kind of binary relation, because most results on finite graphs either do not extend to the infinite case or need a rather different proof.

An empty graph is a graph that has an empty set of vertices (and thus an empty set of edges). The order of a graph is its number | V | of vertices, usually denoted by n. The size of a graph is its number | E | of edges, typically denoted by m. However, in some contexts, such as for expressing the computational complexity of algorithms, the term size is used for the quantity | V | + | E | (otherwise, a non-empty graph could have size 0). The degree or valency of a vertex is the number of edges that are incident to it; for graphs with loops, a loop is counted twice.

In a graph of order n, the maximum degree of each vertex is n − 1 (or n + 1 if loops are allowed, because a loop contributes 2 to the degree), and the maximum number of edges is n (n − 1)/2 (or n (n + 1)/2 if loops are allowed).

The edges of a graph define a symmetric relation on the vertices, called the adjacency relation. Specifically, two vertices x and y are adjacent if { x, y } is an edge. A graph is fully determined by its adjacency matrix A, which is an n × n square matrix, with A specifying the number of connections from vertex i to vertex j. For a simple graph, A is either 0, indicating disconnection, or 1, indicating connection; moreover A = 0 because an edge in a simple graph cannot start and end at the same vertex. Graphs with self-loops will be characterized by some or all A being equal to a positive integer, and multigraphs (with multiple edges between vertices) will be characterized by some or all A being equal to a positive integer. Undirected graphs will have a symmetric adjacency matrix (meaning A = A).
detectable_format:constrained_response