You are on page 1of 3

Graph Concepts

Definitions: Let V be a non-empty set, and E be any set of ordered pairs over V.

• Graph: The pair (V, E); We denote a graph by G = (V, E).


• V is called the vertex set of G and its elements as vertices.
• E is called the edge set of G and its elements as edges.
• Vertices are said to be adjacent if there is an edge that joins them.
• Edges are said to be adjacent if they share a common vertex.
• Degree of a vertex: number of edges at that vertex.
• For graphs with loops, you have to add 1 to the degree of the vertex with loops.
• Path: sequence of vertices with no repeated edges.
• Circuit: a path that starts and ends at the same vertex.
• A graph G is said to be connected if there is a path joining any two of its vertices. Otherwise, it is said to be
disconnected.
Euler’s Theorems and Fleury’s Algorithm

• Bridge: An edge in G is said to be a bridge if G becomes disconnected when it is deleted.


• Euler path: A path that travels through every edge of G.
• Euler circuit: A circuit that travels through every edge of G.
• Euler’s Theorems:
o Euler’s Theorem 1
▪ If a graph has any vertices of odd degree, then it cannot have an Euler circuit.
▪ If a graph is connected and every vertex has an even degree, then it has at least one Euler
circuit.
o Euler’s Theorem 2
▪ If a graph has more than two vertices of odd degree, then it cannot have an Euler path.
▪ If a graph is connected and has just two vertices of odd degree, then it has at least one Euler
path. Any such path must start at one of the odd-degree vertices and end at the other one.
o Euler’s Theorem 3
▪ The sum of the degrees of all the vertices of a graph equals twice the number of edges.
▪ The number of vertices of odd degree must be even.
• Fleury’s Algorithm for Finding Eulerian Circuit (Don’t cross the bridge until you have to)
o Make sure that the graph is connected, and all vertices have even degree.
o Start at any vertex.
o Travel through an edge if:
▪ It is not a bridge for the untraveled part, or
▪ There is no other alternative.
o Label the edges in the order in which you travel them.
o When you can’t travel any more, stop.
Hamilton Circuits, Hamilton Paths, Traveling Salesman Problem

• 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.

You might also like