Date post: | 09-Jan-2017 |
Category: |
Technology |
Upload: | darwish-ahmad-herati |
View: | 779 times |
Download: | 5 times |
1/48
Theoretical SectionPractical Section
INTRODUCTION TO GRAPH AND GRAPHCOLORING PROBLEM
Design Methods and Analysis of AlgorithmDarwish Ahmad Herati
St. Joseph’s College (Autonomous)Computer Science Department
MSc (Computer Science)
SUPERVISORProf. Ms. Mrinmoyee Bhattacharya
September 1, 2015
Darwish Ahmad Herati Design Methods and analysis of Algorithm
2/48
Theoretical SectionPractical Section
Contents
1 Theoretical SectionIntroductionHistoryDefinitionsAlgorithmComplexityApplications
2 Practical SectionExamplesImplementationSimulation Technologies
Darwish Ahmad Herati Design Methods and analysis of Algorithm
3/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Introduction to Graph:
A graph is a collection (nonempty set) of vertices andedgesA graph G is a set of vertex (nodes) v connected by edges(links) e. Thus G=(v , e).
Darwish Ahmad Herati Design Methods and analysis of Algorithm
4/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Example of Graphs:
Darwish Ahmad Herati Design Methods and analysis of Algorithm
5/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Introduction to Graphs:
A graph is a mathematical object that is used to modeldifferent situations objects and processes:
- Linked list- Tree(Special type of graph)- Flowchart chart of a program- Structure chart of a program- Finite state automata- Electric Circuits- Course Curriculum- etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
6/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Vertex (Node):Edge (Link):Adjacent Vertices:Sub-Graph:Directed Graph:Undirected Graph:Connected Graph:Unconnected Graph:
Paths:Simple path:Cycles:Loop:Trees:Spanning tree of a graph:Complete graphs:Weighted graphs:Networks:
Darwish Ahmad Herati Design Methods and analysis of Algorithm
7/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Chromatic Number:K-coloring:Optimal Coloring:etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
8/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Vertex (Node): can have names and propertiesEdge (Link): connect two vertices, can be labeled, can bedirectedAdjacent Vertices: if there is an edge between them.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
9/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Subgraph: A subgraph S of a graph G is a graph whoseset of vertices and set of edges are all subsets of G.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
10/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Directed Graph: In directedgraphs the edges are oriented,they have a beginning and anend. Thus A B and B A aredifferent edges.Sometimes the edges of adirected graph are called arcs.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
11/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Undirected Graph: Inundirected graphs the edges aresymmetrical, e.g. if A and B arevertices, A B and B A are oneand the same edge. Graph1above is undirected.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
12/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Connected Graph: There is a path between each twovertices.Unconnected Graph: There are at least two vertices notconnected by a path.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
13/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
paths: A path is a list of vertices in which successivevertices are connected by edgesSimple Path: No vertex is repeated.Some paths in Graph1 :A B C DA C B A C DA BD C BC B ASome paths in Graph2:D A BA D A C
Darwish Ahmad Herati Design Methods and analysis of Algorithm
14/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Cycles:A cycle is a simple path with distinct edges, wherethe first vertex is equal to the last.Cycles in Graph1:C A B C, C B A C, A B C A, A C B A, B A C B, B C A B A BA is not a cycle, because the edge A B is the same as B ALoop: An edge that connects the vertex with itself
Darwish Ahmad Herati Design Methods and analysis of Algorithm
15/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Trees:A tree is an undirected graph with no cycles and avertex chosen to be the root of the tree.Note: in a tree, when we choose a root we impose anorientation. Given an acyclic graph, we may choose anynode to be the root of a tree.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
16/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Spanning Tree of a Graph: A spanning tree of anundirected graph is a subgraph that contains all thevertices, and no cycles. If we add any edge to the spanningtree, it forms a cycle, and the tree becomes a graph.It is possible to define a spanning tree for directed graphs,however the definition is rather complicated and will not bediscussed here.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
17/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:Complete Graphs:Graphs with all edges present eachvertex is connected to all other vertices, are calledcomplete graphs.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
18/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Weighted Graphs: Weights areassigned to each edge(e.g. distances in a road map)
Darwish Ahmad Herati Design Methods and analysis of Algorithm
19/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Networks:Directed weightedgraphsNote:Some textbooks definenetworks to be undirectedweighted graphs as well.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
20/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Terminologies of Graphs:
Chromatic Number: The chromatic number of a graph Gis the smallest number k for which a k-coloring of thevertices of G is possible.We will use the notation x(G) todenote the chromatic number of G.k-coloring: A k-coloring of a graph G is a coloring of thevertices of G using k colors and satisfying the requirementthat adjacent vertices are colored with different colors.Optimal Coloring: An optimal coloring of a graph G is acoloring of the vertices of G using the fewest possiblenumber of colors.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
21/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Introduction to Graph Coloring
Graph coloring is one of the oldest concepts in the theoryof graphs,A graph G = (V, E) consists two sets where one is the setof vertices and another is the set of edges such that eachedges is associated with an un ordered pair of vertices andgraph coloring is one of the most useful models in graphtheory. Graph coloring is the way of coloring the vertices ofa graph with the minimum number of colors such that notwo adjacent vertices share the same color.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
22/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Introduction to Graph Coloring
A k-coloring of graph G is an assignment of integers{1, 2, . . . ,k} (the colors) to the vertices of G in such a waythat neighbors receive different integers. The chromaticnumber of G is the smallest k such that G has a k-coloring.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
23/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Types of Graph Coloring:
Vertix Coloring:Edge Coloring:Face Coloring/ Map Coloring:
Darwish Ahmad Herati Design Methods and analysis of Algorithm
24/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Vertix Coloring of Graph:
Vertix Coloring:A vertex coloring of a graph is to color thevertices of the graph in such a way that any two adjacentvertices receive different colors.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
25/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Edge Coloring of Graph:Edge Coloring:An edge coloring of a graph is to color theedges of the graph in such a way that any two adjacentedges receive different colors.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
26/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Face Coloring / Map Coloring of Graph:
Face Coloring/ Map Coloring:
Darwish Ahmad Herati Design Methods and analysis of Algorithm
27/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Francis Guthrie and Demorgan
Darwish Ahmad Herati Design Methods and analysis of Algorithm
28/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Cayley and Kempe 1879
Darwish Ahmad Herati Design Methods and analysis of Algorithm
29/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Percy John Heawood 1890
Darwish Ahmad Herati Design Methods and analysis of Algorithm
30/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
K. Appel W. Haken 1977
Darwish Ahmad Herati Design Methods and analysis of Algorithm
31/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Rebertson, Sanders, Seymour, Thomas
Darwish Ahmad Herati Design Methods and analysis of Algorithm
32/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Definitions:
An n-coloring is proper if no pair of adjacent vertices getsthe same color.The graph coloring problem involves assigning values (orcolors) to the vertices of a graph so that adjacent verticesare assigned distinct colors. With the objective ofminimizing the number of colors used.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
33/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Greedy Algorithm for Graph Coloring:
Step 1. Assign the first color (c1) to the first vertex (v1).Step 2. Vertex v2 is assigned color c1 if it is not adjacentto v1; otherwise it gets assigned color c2.Steps 3,4,...,n. Vertex v1 is assigned the first possiblecolor in the priority list of colors (i.e. the first color that hasnot been assigned to one of the already colored neighborsof vi ).
Darwish Ahmad Herati Design Methods and analysis of Algorithm
34/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Analysis of Graph Coloring:An Upper bound on the computing time of MCOLORINGcan arrived by finding the number of internal nodes in thestate space tree is:
At each internal node, O(mn) time is spent by Next Valueto determine the children corresponding to legal coloring.Hence the total time is bounded by:
Darwish Ahmad Herati Design Methods and analysis of Algorithm
35/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Applications of Graph Coloring:
Graph Coloring: has many applications in jobscheduling, assignments of classes/classrooms,assignments of wireless channels.Aircraft scheduling:Making Schedule or Time Table:Mobile Radio Frequency Assignment:Suduku:Register Allocation:Bipartite Graphs:Map Coloring:etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
36/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Aircraft Scheduling:
Aircraft scheduling: Assume that we have k aircrafts,and we have to assign them to n flights, where the ith flightis during the time interval (ai, bi). Clearly, if two flightsoverlap, then we cannot assign the same aircraft to bothflights. The vertices of the conflict graph correspond to theflights, two vertices are connected if the correspondingtime intervals overlap. Therefore the conflict graph is aninterval graph, which can be colored optimally inpolynomial time.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
37/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Making Schedule or Time Table:Making Schedule or Time Table: Suppose we want tomake am exam schedule for a university. We have listdifferent subjects and students enrolled in every subject.Many subjects would have common students (of samebatch, some backlog students, etc). How do we schedulethe exam so that no two exams with a common student arescheduled at same time? How many minimum time slotsare needed to schedule all exams? This problem can berepresented as a graph where every vertex is a subjectand an edge between two vertices mean there is acommon student. So this is a graph coloring problemwhere minimum number of time slots is equal to thechromatic number of the graph.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
38/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Mobile Radio Frequency Assignment:
Mobile Radio Frequency Assignment: Whenfrequencies are assigned to towers, frequencies assignedto all towers at the same location must be different. How toassign frequencies with this constraint? What is theminimum number of frequencies needed? This problem isalso an instance of graph coloring problem where everytower represents a vertex and an edge between two towersrepresents that they are in range of each other.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
39/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Suduku:
Suduku: Suduku is also a variation of Graph coloringproblem where every cell represents a vertex. There is anedge between two vertices if they are in same row or samecolumn or same block.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
40/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Register Allocation:
Register Allocation: In compiler optimization, registerallocation is the process of assigning a large number oftarget program variables onto a small number of CPUregisters. This problem is also a graph coloring problem.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
41/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Bipartite:
Bipartite Graphs: We can check if a graph is Bipartite ornot by colowing the graph using two colors. If a givengraph is 2-colorable, then it is Bipartite, otherwise not. Seethis for more details.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
42/48
Theoretical SectionPractical Section
IntroductionHistoryDefinitionsAlgorithmComplexityApplications
Map Coloring:
Map Coloring: Geographical maps of countries or stateswhere no two adjacent cities cannot be assigned samecolor. Four colors are sufficient to color any map (See FourColor Theorem)
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
43/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Coloring Examples:
: Vertex Coloring: Vertix Coloring: Vertix Coloring: Edge Coloring: Both Vertex & Edge: Face Coloring: Map Coloring
Darwish Ahmad Herati Design Methods and analysis of Algorithm
44/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Implementation of Graphs using C++:
Implementation:Two Graphs using Greedy MethodImplementation in C++.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
45/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Theorem Simulation Technologies:
1st: DemonstrationProgram2nd: CGraph Simulator3rd: GraphTeaSimulator4th: Graph Magic5th: etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
45/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Theorem Simulation Technologies:
1st: DemonstrationProgram2nd: CGraph Simulator3rd: GraphTeaSimulator4th: Graph Magic5th: etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
45/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Theorem Simulation Technologies:
1st: DemonstrationProgram2nd: CGraph Simulator3rd: GraphTeaSimulator4th: Graph Magic5th: etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
45/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Theorem Simulation Technologies:
1st: DemonstrationProgram2nd: CGraph Simulator3rd: GraphTeaSimulator4th: Graph Magic5th: etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
45/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Graph Theorem Simulation Technologies:
1st: DemonstrationProgram2nd: CGraph Simulator3rd: GraphTeaSimulator4th: Graph Magic5th: etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
46/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
References
Srikanth.S, (2014). Design and Analysis of AlgorithmsTommy R. Jensen and Bjarne Toft, (1995) Graph ColoringProblemsLydia Sinapova. (2015)(http://faculty.simpson.edu/lydia.sinapova/www/cmsc250/LN250_Weiss/L19-Graphs.htm) . Accessed Augest 252015.etc.
Darwish Ahmad Herati Design Methods and analysis of Algorithm
47/48
Theoretical SectionPractical Section
ExamplesImplementationSimulation Technologies
Thank You For YourAttention
Darwish Ahmad Herati Design Methods and analysis of Algorithm