3 - Graphs
Published online by Cambridge University Press: 10 November 2016
Summary
Extending the Relationships between Records
In a generalization of the linear lists of the previous chapter, we may allow the connection between any two elements, without insisting on some specific order. The resulting structure is known as a graph. This models quite naturally several real life situations, like networks of communicating computers, or road systems connecting the various locations of some neighborhood.We shall, however, see that a graph may be a useful tool for many other applications, some of which seeming a priori completely unconnected to a graph structure.
Mathematically, a graph G is defined as a pair of sets G = (V, E). There is no restriction on the set V, called the vertices of the graph, and its elements are usually denoted, or simply. The set of edges E satisfies and actually describes whether some binary relation exists between certain pairs of vertices.Wemay have or, in which cases the graph is called empty or full, respectively. Note that this refers only to the number of edges, so a graph may be empty and yet have many vertices. The complexities of algorithms involving graphs are often given as a function of the sizes of V and E, for example, but it has become common practice to simplify this notation to when no confusion can arise.
It is customary, and often very helpful as a visual aid, to represent a graph by a drawing in which the vertices appear as dots or circles, and an edge (a, b) as an arrow from the circle corresponding to a to that of b. Figure 3.1 is such a drawing for a graph with and, and will serve as a running example in this chapter. It should be emphasized that this drawing is not the graph G itself, but rather one of its infinitely many possible representations. Indeed, there are almost no restrictions on the layout of the drawing: the circles representing the vertices are generally scattered in any visually appealing way, the edges may be straight lines or arcs or have any other form, they may cross each other, etc.
- Type
- Chapter
- Information
- Basic Concepts in Data Structures , pp. 33 - 49Publisher: Cambridge University PressPrint publication year: 2016