Professional Documents
Culture Documents
Graph Theory
Graph Theory
Definitions: Let V be a non-empty set, and E be any set of ordered pairs over V.
• Hamilton Circuit: A circuit that passes through each vertex exactly once.
• Hamilton Path: A path that passes through each vertex exactly once.
• A graph Kn with n vertices is said to be a complete graph if every vertex is adjacent to the other (n − 1)
vertices.
• A weighted graph is a graph whose edges have assigned numbers. Such numbers are called weights.
Common weights are time, distance and cost. Complete graphs that are weighted are simply called complete
weighted graphs.
• Brute Force Method:
o Draw a complete weighted graph for the problem.
o List all possible Hamilton circuits.
o Find the sum of the weights of the edges for each circuit.
o The circuit with the smallest sum is the optimal solution.
• Nearest Neighbor Method
o Draw a complete weighted graph for the problem.
o Starting at a designated vertex, pick the edge with the smallest weight and move to the second vertex.
o At the next vertex, pick the edge with smallest weight that doesn’t go to a vertex already used.
o Continue until the circuit is completed.
o The sum of the weights is an approximation to the optimal solution.
• Cheapest Link Algorithm
o Draw a complete weighted graph for the problem.
o Pick the edge with the smallest overall weight. In case of a tie, pick at random.
o Pick the edge with the next smallest overall weight that doesn’t:
▪ Enclose a smaller circuit that doesn’t reach every vertex or
▪ Result in three chosen edges coming from the same vertex.
o Repeat Step 2 until the Hamilton circuit is complete.
Spanning Trees and Kruskal’s Algorithm
• Tree: graph in which any two vertices are connected by exactly one path.
o A tree has no circuits.
o Trees are connected graphs.
o Every edge in a tree is a bridge.
o A tree with n vertices has exactly (n − 1) edges.
• Spanning Tree: For a connected graph G of n vertices is a connected subgraph that is a tree on n vertices;
tree that results from the removal of as many edges as possible from the original graph without making it
disconnected.
• Minimum spanning tree for a weighted graph: the spanning tree for that graph that has the smallest
possible sum of the weights.
• Kruskal’s Algorithm
o Choose the edge with the lowest weight (and highlight it in color). If there is more than one, pick one
at random.
o Choose the unmarked edge with the next lowest weight that does not form a circuit with the edges
already highlighted, (and highlight it).
o Repeat until all vertices have been connected. That is the minimum spanning tree for a weighted graph.
Graph Coloring
• Graph coloring: a function that assigns either the vertices or edges of a graph by a unique color (or label).
Either vertex coloring or edge coloring depending on whether the vertices or the edges are labelled.
• Planar graph: can be drawn in a plane without the edges crossing.
• Chromatic number: the smallest number of colors needed to color a graph.
• Four-color Theorem: Every possible geographical map can be colored with at most four colors in such a
way that no two adjacent regions have the same color.
• Vertex Coloring Algorithm
o Determine the vertex with the highest degree. Assign it the first color.
o Also, assign the first color to all vertices that are not adjacent to the first chosen vertex.
o Among the remaining vertices, determine the vertex with the highest degree. Assign to it the second
color.
o Also, assign the second color to all vertices that are neither adjacent to the second chosen vertex nor
to vertices that already received the second color.
o Continue doing Steps 3 and 4 until all vertices are colored.
o The number of colors used is the chromatic number.