Definitions in graph theory vary. The following are some of the more basic ways of defining graphs and related
mathematical structures.
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 , where is a set whose elements are called
vertices (singular: vertex), and is a set of unordered pairs \{v_1, v_2\} of vertices, whose elements are called
edges (sometimes
links or
lines). 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 of vertices, usually denoted by . The
size of a graph is its number of edges, typically denoted by . However, in some contexts, such as for expressing the
computational complexity of algorithms, the term
size is used for the quantity (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. The vertices and of an edge {{math|{
u,
v} }} are called the edge's
endpoints. The edge is said to
join and 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\} exists, the vertices and 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 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 is taken to be finite (which implies that the edge set 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. In a graph of order , the maximum degree of each vertex is (or if loops are allowed, because a loop contributes 2 to the degree), and the maximum number of edges is (or if loops are allowed). The edges of a graph define a
symmetric relation on the vertices, called the
adjacency relation. Specifically, two vertices and are
adjacent if {{math|{
x,
y} }} is an edge. A graph is fully determined by its
adjacency matrix , which is an square matrix, with specifying the number of connections from vertex to vertex . For a simple graph, is either 0, indicating disconnection, or 1, indicating connection; moreover 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 being equal to a positive integer, and multigraphs (with multiple edges between vertices) will be characterized by some or all being equal to a positive integer. Undirected graphs will have a
symmetric adjacency matrix (meaning ).
Directed graph A
directed graph or
digraph is a graph in which edges have orientations. In one restricted but very common sense of the term, a
directed graph is a pair comprising: • , a
set of
vertices (also called
nodes or
points); • , a
set of
edges (also called
directed edges,
directed links,
directed lines,
arrows, or
arcs), which are
ordered pairs of distinct vertices: E \subseteq \{(x,y) \mid (x,y) \in V^2 \;\textrm{ and }\; x \neq y \}. To avoid ambiguity, this type of object may be called precisely a
directed simple graph. In the edge directed from to , the vertices and are called the
endpoints of the edge, the
tail of the edge and the
head of the edge. The edge is said to
join and and to be
incident on and on . A vertex may exist in a graph and not belong to an edge. The edge is called the
inverted edge of .
Multiple edges, not allowed under the definition above, are two or more edges with both the same tail and the same head. In one more general sense of the term allowing multiple edges, a directed graph is sometimes defined to be an ordered triple comprising: • , a
set of
vertices (also called
nodes or
points); • , a
set of
edges (also called
directed edges,
directed links,
directed lines,
arrows or
arcs); • , an
incidence function mapping every edge to an
ordered pair of vertices (that is, an edge is associated with two distinct vertices): \phi : E \to \{(x,y) \mid (x,y) \in V^2 \;\textrm{ and }\; x \neq y \}. To avoid ambiguity, this type of object may be called precisely a
directed multigraph. A
loop is an edge that joins a vertex to itself. Directed graphs as defined in the two definitions above cannot have loops, because a loop joining a vertex x to itself is the edge (for a directed simple graph) or is incident on (for a directed multigraph) (x,x) which is not in \{(x,y) \mid (x,y) \in V^2 \;\textrm{ and }\; x \neq y \}. So to allow loops the definitions must be expanded. For directed simple graphs, the definition of E should be modified to E \subseteq V^2. For directed multigraphs, the definition of \phi should be modified to \phi : E \to V^2. To avoid ambiguity, these types of objects may be called precisely a
directed simple graph permitting loops and a
directed multigraph permitting loops (or a
quiver) respectively. The edges of a directed simple graph permitting loops is a
homogeneous relation ~ on the vertices of that is called the
adjacency relation of . Specifically, for each edge , its endpoints and are said to be
adjacent to one another, which is denoted .
Mixed graph A
mixed graph is a graph in which some edges may be directed and some may be undirected. It is an ordered triple for a
mixed simple graph and for a
mixed multigraph with , (the undirected edges), (the directed edges), and defined as above. Directed and undirected graphs are special cases.
Weighted graph A
weighted graph or a
network is a graph in which a number (the weight) is assigned to each edge. Such weights might represent for example costs, lengths or capacities, depending on the problem at hand. Such graphs arise in many contexts, for example in
shortest path problems such as the
traveling salesman problem. == Types of graphs ==