In mathematics and computer science, a graph is the basic object of study in graph theory. Informally speaking, a graph is a set of objects called points, vertices, or nodes, connected by links called respectively lines, edges, or arcs. In a proper graph, which is by default undirected, a line from point A to point B is considered to be the same thing as a line from point B to point A. In a digraph, short for directed graph, the two directions are counted as being distinct arcs or directed edges.
Typically, a graph is depicted in diagrammatic form as a set of dots (for the points, vertices, or nodes), joined by curves (for the lines or edges).
A graph or undirected graph is an ordered pair that is subject to the following conditions:
(Note that this defines the most general type of graph. Some authors call this a multigraph or pseudograph and reserve the term "graph" for simple graphs.)
The vertices belonging to an edge are called the ends, endpoints, or end vertices of the edge.
(and hence ) are usually taken to be finite, and many of the well-known results are not true (or are rather different) for infinite graphs because many of the arguments fail in the infinite case. The order of a graph is (the number of vertices). A graph's size is , the number of edges. The degree of a vertex is the number of edges that connect to it, where an edge that connects to the vertex at both ends (a loop) is counted twice.
The edges induce a symmetric binary relation ~ on which is called the adjacency relation of . Specifically, for each edge {u,v} the vertices u and v are said to be adjacent to one another, which is denoted u ~ v.
For an edge {u, v}, graph theorists usually use the somewhat shorter notation uv.
Most commonly, in modern texts in graph theory, unless stated otherwise, the term "graph" means "undirected simple finite graph" (see the definitions below).
A directed graph or digraph is an ordered pair with
An arc is considered to be directed from to ; is called the head and is called the tail of the arc; is said to be a direct successor of , and is said to be a direct predecessor of . If a path leads from to , then is said to be a successor of , and is said to be a predecessor of . The arc is called the arc inverted.
A directed graph G is called symmetric if, for every arc that belongs to G, the corresponding inverted arc also belongs to G. A symmetric loopless directed graph is equivalent to an undirected graph with the pairs of inverted arcs replaced with edges; thus the number of edges is equal to the number of arcs halved.
A variation on this definition is the oriented graph, which is a graph (or multigraph; see below) with an orientation or direction assigned to each of its edges. A distinction between a directed graph and an oriented simple graph is that if and are vertices, a directed graph allows both and as edges, while only one is permitted in an oriented graph.
The term "multigraph" is generally understood to mean that multiple edges (and sometimes loops) are allowed. Where graphs are defined so as to allow loops and multiple edges, a multigraph is often defined to mean a graph without loops, however, where graphs are defined so as to disallow loops and multiple edges, the term is often defined to mean a "graph" which can have both multiple edges and loops, although many use the term "pseudograph" for this meaning.
As opposed to a multigraph, a simple graph is an undirected graph that has no self-loops and no more than one edge between any two different vertices. In a simple graph the edges of the graph form a set (rather than a multiset) and each edge is a pair of distinct vertices. In a simple graph with p vertices every vertex has a degree that is less than p (the inverse, however, is not true - there exist non-simple graphs with p vertices in which every vertex has a degree smaller than p).
The weight of the graph is sum of the weights given to all edges.
Most commonly in graph theory it is implied that the discussed graphs are finite, i.e., finite graphs are called simply "graphs", while the infinite graphs are called so in full.
In an undirected graph G, two vertices u and v are called connected if G contains a path from u to v. Otherwise, they are called disconnected. A graph is called connected if every pair of distinct vertices in the graph is connected and disconnected otherwise.
A graph is called k-vertex-connected or k-edge-connected if removal of k or more vertices (respectively, edges) makes the graph disconnected. A k-vertex-connected graph is often called simply k-connected.
A directed graph is called weakly connected if replacing all of its directed edges with undirected edges produces a connected (undirected) graph. It is strongly connected or strong if it contains a directed path from u to v and a directed path from v to u for every pair of vertices u,v.
Two edges of a graph are called adjacent (sometimes coincident) if they share a common vertex. Two arrows of a directed graph are called consecutive if the head of the first one is at the nock (notch end) of the second one. Similarly, two vertices are called adjacent if they share a common edge (consecutive if they are at the notch and at the head of an arrow), in which case the common edge is said to join the two vertices. An edge and a vertex on that edge are called incident.
The graph with only one vertex and no edges is called the trivial graph. A graph with only vertices and no edges is known as an edgeless graph. The graph with no vertices and no edges is sometimes called the null graph or empty graph, but not all mathematicians allow this object.
In a weighted graph or digraph, each edge is associated with some value, variously called its cost, weight, length or other term depending on the application; such graphs arise in many contexts, for example in optimal routing problems such as the traveling salesman problem.
Normally, the vertices of a graph, by their nature as elements of a set, are distinguishable. This kind of graph may be called vertex-labeled. However, for many questions it is better to treat vertices as indistinguishable; then the graph may be called unlabeled. (Of course, the vertices may be still distinguishable by the properties of the graph itself, e.g., by the numbers of incident edges). The same remarks apply to edges, so that graphs which have labeled edges are called edge-labeled graphs. Graphs with labels attached to edges or vertices are more generally designated as labeled. Consequently, graphs in which vertices are indistinguishable and edges are indistinguishable are called unlabeled. (Note that in the literature the term labeled may apply to other kinds of labeling, besides that which serves only to distinguish different vertices or edges.)
The picture is a graphic representation of the following graph
The fact that vertex 1 is adjacent to vertex 2 is sometimes denoted by 1 ~ 2.
More advanced kinds of graphs are:
There are several operations that produce new graphs from old ones. They may be separated into three categories
An undirected graph can be seen as a simplicial complex consisting of 1-simplices (the edges) and 0-simplices (the vertices). As such, complexes are generalizations of graphs since they allow for higher-dimensional simplices.
Every graph gives rise to a matroid.
In model theory, a graph is just a structure. But in that case, there is no limitation on the number of edges: it can be any cardinal number.
In computational biology, power graph analysis introduces power graphs as an alternative representation of undirected graphs.