Considering the essence of a graph
Graphs appear as ordered pairs in the form G = (V,E), where G is the graph, V is a
list of vertexes, and E is a list of edges that connect the vertexes. An edge is actu-
ally a numeric pair that expresses the two vertexes that it connects. Consequently,
if you have two vertexes that represent cities, Houston (which equals 1) and Dallas
(which equals 2), and you want to connect them with a road, then you create an
edge,
Highway
, that contains a pair of vertex references,
Highway = [Houston,
Dallas]
. The graph would appear as
G = [(Houston, Dallas)]
, which simply
says that there is a first vertex, Houston, with a connection to Dallas, the second
vertex. Using the order of presentation of the vertexes, Houston is adjacent to
Dallas; in other words, a car would leave Houston and enter Dallas.
CHAPTER 8
Do'stlaringiz bilan baham: |