Professional Documents
Culture Documents
Graphs are composed of two components: vertices and edges. Vertices are essentially points. (They are also referred to as nodes.) Typically, they will be labeled on a graph. In an ndirected graph, edges are simply lines in between pairs of vertices. !o, for e"ample, in a graph with n vertices, the ma"im m n mber of edges is n#$ % n(n&')($. This is the n mber of edges in a complete graph. ) complete graph is a graph where there e"ists an edge between all pairs of vertices. *e will define the degree of each verte" of a graph to be the n mber of edges that are incident to that verte". ) walk in a graph is a se+ ence of edges that can be traversed one by one. (This essentially means that the endpoint of an edge in a path has to be the starting point of the ne"t edge in the path.) It is permissible for a wal, to start and end in the same place. (-r, of co rse, start and end in different places.) ) graph is connected if there e"ists a path in between all pairs of vertices. .ere is an e"ample of a ndirected graph:
/irected Graphs
The only difference between a directed graph and an ndirected one is how the edges are defined. In an ndirected graph, an edge is simply defined by the two vertices it connects. 0 t, in a directed graph, the 1direction2 of the edge matters. 3or e"ample, let4s say a graph has two vertices v and w. In a directed graph with these two vertices, we wo ld be allowed to have more than one edge. *e co ld have an edge from v T- w, and another one from w T- v. In essence, each edge not only connects a pair of vertices, b t also has a direction associated with it. Using a formal definition, the set of edges of a directed graph G can be defined as a s bset of the cartesian prod ct V " V, where V is the set of vertices. )ll of the other definitions listed for ndirected graphs apply to directed ones. )lso, when we tal, abo t the degree of a verte" in a directed graph, we have to disting ish between the 1in2 degree and the 1o t2 degree. )t each verte", edges are either coming in or going o t. The in degree of a verte" is simply the s m of the n mber of edge coming in to that verte". The o t degree is defined similarly.
It t rns o t that this is a s fficient and necessary condition. *hat that means is that if a graph has an even degree at each verte", it definitely has an 7 ler circ it. *e also ,now that the s m of the degrees of the vertices of a graph is $ times the n mber of edges. *hy6 This is typically called the handsha,ing lemma, which basically says in any sit ation where " n mber of people sha,e hands with each other, the total n mber of handsha,es s mmed over all of these people m st be an even n mber. The :TV view of loo,ing at the handsha,ing lemma wo ld be if yo as,ed everyone in the world how many people they4ve had se" with (or how many times they have had se"), and added p all the responses, yo 4d have to get an even n mber, ( nless yo incl de threesomes, in the mi", of co rse;;;)