Presentation on theme: "Directed graphs Reachability A graph where direction is indicated for every edge is called a directed graph or digraph. Reachability is about reaching."— Presentation transcript:
Directed graphs Reachability A graph where direction is indicated for every edge is called a directed graph or digraph. Reachability is about reaching for example from one city ti the other. One point in a network is said to be reachable from another different point in a directed graph if a path exists between the two points. For example, in the directed graph shown: B is reachable from A in one step( one edge) along the path AB. C is reachable from A in one step along the path AC. C is also reachable from A in two steps (two edges) along the path A-B-C. D is not reachable from A ( no edges).
We record the reachability properties of a directed graph by constructing a series of matrices as shown below. The ﬁrst matrix R 1 (reachability 1) records the number of one-step paths between each of the vertices. The R 1 matrix is also an adjacency matix as it represents whether there is a direct connection between two vertices. The second matrix R 2 records the number of two-step paths between each of the vertices. The third matrix R 3 records the number of three-step paths between each of the vertices.
We combine this information into the total reachability matrix R, which will show all possible paths in the directed graph. Using the R matrix, we can then calculate the total reachability of each of the vertices by adding each of the columns and recording the sums in a table.
Dominance Dominance is about winning in competitions. A group of ﬁve tennis players, A, B, C, D and E, play each other in a round robin competition to see who is the best player. The results are as follows: A defeated C and D B defeated A, C and E C defeated D D defeated B E defeated A, C and D We can then use the graph to form a series of dominance matrices. The ﬁrst dominance matrix D 1 records the number of one-step dominances between the players. D 1 is also an adjacency matrix.
The second dominance matrix D 2 records the number of two-step dominances between the players. D which takes into account both one-step and two-step dominances. The total dominance of each vertex is counted by adding each row.
Network flows A ﬂow is the quantity of material that can move along a given channel; for example, trafﬁc ﬂow along a highway or water ﬂow through a pipe. Determining the maximum flow The method of determining the maximum ﬂow for a network is to use the minimum capacity of cuts. A cut is a line through the graph so that the sourse ( the point that the flow starts) is seperated from the sink ( the point that the flow finishes).The capacity of a cut is the sum of the weights of the edges that are crossed by the cut. However if the cut is blocked by another initial cut then its capacity is not counted. The capacity of the cut in the diagram below is = 7
Example: Determine the minimum cut and therefore the maximum flow of the diagram below: Solution: a Draw all the possible cuts on the diagram i.e. C 1, C 2, C 3, C 4 b Determine the capacity of each cut: C 1 = = 7 C 2 = = 11( the flow of the edge AB is not counted as it is blocked by CB). C 3 = = 8 C 4 = = 8 c Determine the minimum cut by comparing the capacities. Minimum cut = 7
Example:Determine the capacities of each of the cuts in the graph shown, and also the value of the minimum cut and hence the maximum ﬂow. Solution The capacity of C1 = = 35. The capacity of C2 = = 56. The capacity of C3 = = 49. The capacity of C4 = = 30. The capacity of C5 = = 25. ∴ the maximum flow = 25.
Example:Determine the maximum ﬂow for the directed graph. Solution The capacity of C1 = = 19. The capacity of C2 = = 14. The capacity of C3 = = 12. The capacity of C4 = = 9. The capacity of C5 = = 7. ∴ the maximum flow = 7.
Critical path When we are preparing a meal, for example chips, steak and salad we usually want all the parts of the meal to be ready at the same time. Some of the parts can be done at the same time, other cannot be started untill other activities are completed. Some parts take longer time to prepare and other less. The following table shows the time that it takes each part of the meal. ActivityDurationPredecessors A. Preperation of steak (salt,pepper) 10 minutes - B. Grilling the steak15 minutesA C. Preperation of the greens (wash) 10 minutes - D. Cut the salad, salt, oil, vinegar 10 minutesC E. Peel and cut potatoes, heat the oil 30 minutes - F. Fry the potatoes30 minutesE G. eat the meal. Eat the meal with people you are enjoying. 40 minutesB, D, F
From the previews table we can get a network diagram for the project. The activities are represented as edges. The activities A, E, C will start first as there are no predecessors. If we need to find the total time taken to prepare the meal we need to find the critical path. The critical path is the longest path through the network.The longest path for the network above is E,F,G and the time taken is 1 hour and 40 minutes. The EST is the earliest starting time that an activity can start. The LST is the latest starting time that an activity can start. The critical path is the path through the network along the activities that have the same EST and LST. To find EST of each activity we need to add the duration of all the previews activities to the EST of the original activity. To find the LST of an activity we need to subtract the duration of the activities that are after from the critical path. Slack or float time is the time that can be wasted for the activities that do not belong on the critical path.We can get the slack time by subtracting the EST from the LST of the activities that are not on the critical path. The dummy activity is added to the network if a double edge is formed or if there is a nesecity to add it in order to approprietly connect
Crashing the project: It is possible to speed up a project by reducing the duration of any activity. Reducing the project is reducing the duration of the critical path and possibly change the critical path. Example: a Draw the network of the following table. Find the critical path, the minimum finishing time of the project and the EST and LST of each activity. Activity Duration( days) Predecessors A8- B6- C1A D2B E3C F1C, D G2E, F H1G
Answer: The network is shown below. A dummy activity C,0 had to be added to the network as C is the predecessor for E and C and D is the predecessor for F The critical path is the longest path of the network and goes through the edges A-C-E-G-H When we add the duration of these activities,we get the minimum finishing time taken to complete the whole project. Minimum finishing time = 15 days The slack time of activity B = Latest starting time- Earliest starting time = 3-0 = 3
b.If the duration of A is reduced to 5 days and the duration of E to 2 days what is the minimum finishing time. What is the new critical path? Draw the new network. Answer: Critical path = B-D-F-G-H minimum time = 12 days.
Draw the networks, find the critical paths, minimum times and EST, LST of all activities. ActivityDurationPredecessors A3- B4- C6- D7A E8B F5B G12C H2C J11D, E K10F L3G,M M9H N 6J, K, L
Fill in the gaps by finding the missing EST, LST and the float times if the minimum time to complete the construction is 31 days ActivityEST(earliest starting time)LST( latest starting time)Float time A00 B55 C13 D E F17 G18 H19 I25 J28
Allocation problems Bipartite graphs: are directed graphs where the vertices are seperated into 2 sets, to represent a relationship between two sets and to allocate one set of the graph to the other. Example: There are 4 people to be allocated to complete 4 tasks. Each person needs to be allocated to complete a task. Aaron can do task 2 and task 4 Barbara can do task task 4 Clive can do task 1 and task 4 and Diane can do task 1, task 2 and task 3 The following bipartite graph represents the relationship Solution:Barbara can only do task 4, so task 4 has to be given to Barbara. That means that Aaron has to do task 2 and Clive task 1.Diane is left with task 3
The following bipartite graph represents the results of the allocation HUNGARIAN ALGORITHM We use Hungarian algorithm for assignment problems that involve weightings and they have to be completed with the minimum amount ( cost, time).
Example: Operators A,B,C and D are each to be allocated one of four tasks 1, 2, 3, 4. Their estimates of the time in hours, that each of these tasks will take them are summarised in the matrix/table below. How should the tasks be assigned so that the total time to complete all tasks is a minimum? A3657 B4665 C3676 D5566 Solution Step 1: Subtract the minimum from each row A0324 B0221 C0343 D0011
Step 2: Subtract the minimum from each column A0313 B0210 C0332 D0000 Step 3: Cover the 0’s with the minimum lines. If it is 4×4 matrix we need 4 lines. If the lines are less than 4 then we need to continue to step 4. Only three lines are needed to cover the the 0’s so we need to proceed to step A0324 B0221 C0343 D0011
Step 4: Add the minimum uncovered number to all the numbers that are covered. If the number is covered twice the you add it twice. The minimum uncovered number is A1313 B2321 C1332 D2111 Step 5: Subtract the minimum number of all entries. Cover the 0’s with the minimum number of lines A0202 B1210 C0221 D1000
Step 6: Do the allocations. The 0’s determine the possible allocations.For example operator can do tasks 1 and 3. Sketch the bipartite graph of the matrix with allocations. AAA Step 7: We find the allocations in the original matrix using the resulting bipartite graph. Add them to find the minimum time needed tocomplete all the tasks A3657 B4665 C3676 D5566 Total minimum time: = 18
Example:Four supermarkets (A, B, C and D) are supplied from four distribution outlets (W, X, Y and Z). The cost in dollars of supplying one vanload of goods is given in the table below.Find the minimum cost of supplying the supermarkets. Solution Step 1: Subtract the minimum from each row. Step 2: Subtract the minimum from each column.
Step 3: Cover the 0’s with the minimum lines. If it is 4×4 matrix we need 4 lines. If the lines are less than 4 then we need to continue to step 4. Step 4: Add the minimum uncovered number to all the numbers that are covered. If the number is covered twice the you add it twice. The minimum uncovered number is 10. Step 5: Subtract the minimum number of all entries. Cover the 0’s with the minimum number of lines.
Step 6: Do the allocations. The 0’s determine the possible allocations. Sketch the bipartite graph of the matrix with allocations. There are two possible choices. Their costs are: