Download presentation
Presentation is loading. Please wait.
Published byDinah Mathews Modified over 9 years ago
1
Data Structures and Algorithms Graphs
2
2Content MotivationMotivation GraphGraph –Directed Graph –Undirected Graph –Representation –Implementation AlgorithmsAlgorithms –Graph Traversal –Shortest Path –Minimum Cost Spanning Trees –Critical Path Analysis
3
3 Motivation... Graphs are everywhere
4
4 Directed Graph
5
5 Definition A directed graph, or digraph, is an ordered pair G = (V, E) with the following properties: 1.The first component, V, is a finite, non-empty set. The elements of V are called the vertices of G. 2.The second component, E, is a finite set of ordered pairs of vertices. That is, E V x V. The elements of are called the edges of G. Example G = (V, E) V = {a, b, c, d} E = { (a,b), (a,c), (b,c), (c,a), (c,d), (d,d) } Remark E cannot contain more than one instance of a given edge. (a,b) is different then (b,a). Eg. Consider a downwhill (a,b) cities. Although the distance is the same, the time it takes to travel a2b and b2a maybe different…. Eg. Consider a downwhill (a,b) cities. Although the distance is the same, the time it takes to travel a2b and b2a maybe different….
6
6 Directed Graph... Head, Tail, Adjacent Terminology Consider a directed graph G = (V, E). Each element of V is called a vertex or a node of G. Hence, V is the set of vertices (or nodes) of G.Each element of V is called a vertex or a node of G. Hence, V is the set of vertices (or nodes) of G. Each element of E is called an edge or an arc of G. Hence, E is the set of edges (or arcs) of G.Each element of E is called an edge or an arc of G. Hence, E is the set of edges (or arcs) of G. An edge (v,w) E can be represented as v w. An arrow that points from v to w is known as a directed arc. Vertex w is called the head of the arc because it is found at the arrow head. Conversely, v is called the tail of the arc. Finally, vertex w is said to be adjacent to vertex v.An edge (v,w) E can be represented as v w. An arrow that points from v to w is known as a directed arc. Vertex w is called the head of the arc because it is found at the arrow head. Conversely, v is called the tail of the arc. Finally, vertex w is said to be adjacent to vertex v.
7
7 Directed Graph... Out-degree, In-degree Terminology Consider a directed graph G = (V, E). An edge e=(v,w) is said to emanate from vertex v. We use notation to denote A(v) the set of edges emanating from vertex v. That is, A(v) = {(a,b) E : a=v}An edge e=(v,w) is said to emanate from vertex v. We use notation to denote A(v) the set of edges emanating from vertex v. That is, A(v) = {(a,b) E : a=v} The out-degree of a node is the number of edges emanating from that node. Therefore, the out-degree of v is |A(v)|The out-degree of a node is the number of edges emanating from that node. Therefore, the out-degree of v is |A(v)| An edge e=(v,w) is said to be incident on vertex w. We use notation I(w) to denote the set of edges incident on vertex w. That is, I(w) = {(a,b) E : b=w}An edge e=(v,w) is said to be incident on vertex w. We use notation I(w) to denote the set of edges incident on vertex w. That is, I(w) = {(a,b) E : b=w} The in-degree of a node is the number of edges incident on that node. Therefore, the in-degree of w is |I(v)|The in-degree of a node is the number of edges incident on that node. Therefore, the in-degree of w is |I(v)|
8
8 Directed Graph... Successor, P redecessor Terminology Consider the path P = {v 1, v 2,..., v k } in directed graph G = (V, E). Vertex v i+1 is the successor of vertex v i for 1 i < k. Each element v i of path P (except the last) has a successor.Vertex v i+1 is the successor of vertex v i for 1 i < k. Each element v i of path P (except the last) has a successor. Vertex v i-1 is the predecessor of vertex v i for 1 < i k. Each element v i of path P (except the first) has a predecessor.Vertex v i-1 is the predecessor of vertex v i for 1 < i k. Each element v i of path P (except the first) has a predecessor. Example {a, b, c, d}
9
9 Directed Graph... Path Definition A path in a directed graph G = (V, E) is a non-empty sequence of vertices P = {v 1, v 2,..., v k } where v i V for 1 i k such that (v i, v i+1 ) E for 1 i k. The length of path P is k-1. Example P 1 = (a) P 2 = (b, c) P 3 = (a, b, c) P 4 = (a, c, a, c, a, c, a, c, a, c, a, c, a) Question What is the maximum path length?
10
10 Directed Graph... Simple path, Cycle, Loop Terminology Consider the path P = {v 1, v 2,..., v k } in directed graph G = (V, E). A path P is called a simple path if and only if v i v j for all i and j such that 1 i < j k. However, it is permissible for v 1 = v k.A path P is called a simple path if and only if v i v j for all i and j such that 1 i < j k. However, it is permissible for v 1 = v k. A cycle is a path P of non-zero length in which v 1 = v k. The length of a cycle is just the length of the path P.A cycle is a path P of non-zero length in which v 1 = v k. The length of a cycle is just the length of the path P. A loop is a cycle of length one. That is, it is a path of the form {v, v}.A loop is a cycle of length one. That is, it is a path of the form {v, v}. A simple cycle is a path that is both a cycle and simple.A simple cycle is a path that is both a cycle and simple. Example {a, b, c, d} {c, a, c, d} {a, b, c, a} {a, c, a, c, a}
11
11 Directed Graph... Directed Acyclic Graph Definition A directed, acyclic graph (DAG) is a directed graph that contains no cycles. Remark Trees DAG. DAG Tree
12
12 Undirected Graph
13
13 Undirected Graph Definition An undirected graph is an ordered pair G = (V, E) with the following properties: 1.The first component, V, is a finite, non-empty set. The elements of V are called the vertices of G. 2.The second component, E, is a finite set of sets. Each element of E is a set that is comprised of exactly two (distinct) vertices. The elements of E are called the edges of G. Example G = ( V, E) V = {a, b, c, d} E = { {a,b}, {a,c}, {b,c}, {c,d} } Remark {a,b} = {b,a} undirected *eg. full duplex communication link between nodes{a,b} = {b,a} undirected *eg. full duplex communication link between nodes There cannot be an edge from a node to itself in an undirected graphThere cannot be an edge from a node to itself in an undirected graph
14
14 Undirected Graph... Incident Terminology Consider a undirected graph G = (V, E). An edge e={v,w} E is said to emanate from and incident on both vertices v and w.An edge e={v,w} E is said to emanate from and incident on both vertices v and w. The set of edges emanating from a vertex v is the set A(v) = {(v 0,v 1 ) E : v 0 = v v 1 = v}The set of edges emanating from a vertex v is the set A(v) = {(v 0,v 1 ) E : v 0 = v v 1 = v} The set of edges incident on a vertex w is I(w) = A(w)The set of edges incident on a vertex w is I(w) = A(w)
15
15 Labeled Graph Definition A graph which has been annotated in some way is called a labeled graph. Remark Both edges and vertices can be labeled
16
16 Representation
17
17Representation Consider a directed graph G = (V, E). Since E V V, graph G contains at most |V| 2 edges.Since E V V, graph G contains at most |V| 2 edges. There are possible sets of edges for a given set of vertices.There are possible sets of edges for a given set of vertices.
18
18 Representation... Adjacency Matrix for DAG Consider a directed graph G = (V, E) with V = {v 1, v 2,..., v n }. The simplest graph representation scheme uses an n x n matrix A of zeroes and ones given byThe simplest graph representation scheme uses an n x n matrix A of zeroes and ones given by The matrix A is called an adjacency matrix.The matrix A is called an adjacency matrix.
19
19 Representation... Adjacency Matrix for DAG... ExampleRemark The number of ones in the adjacency matrix is equal to the number of edges in the graphThe number of ones in the adjacency matrix is equal to the number of edges in the graph Each one in the i th row corresponds to an edge that emanates from vertex v i.Each one in the i th row corresponds to an edge that emanates from vertex v i. Each one in the i th column corresponds to an edge incident on vertex v i.Each one in the i th column corresponds to an edge incident on vertex v i.
20
20 Representation... Adjacency Matrix for undirected Represent an undirected graph G = (V, E) with V = {v 1, v 2,..., v n }, using an n x n matrix A of zeroes and ones given by
21
21 Representation... Adjacency Matrix for undirected... ExampleRemark Since {v i, v j } = {v j, v i }, matrix A is symmetric about the diagonal. That is, a ij = a jiSince {v i, v j } = {v j, v i }, matrix A is symmetric about the diagonal. That is, a ij = a ji All of the entries on the diagonal are zero. That is, a ii = 0 for 1 i nAll of the entries on the diagonal are zero. That is, a ii = 0 for 1 i n
22
22 Representation... Adjacency Matrix for undirected... ExampleRemark Since {v i, v j } = {v j, v i }, matrix A is symmetric about the diagonal. That is, a ij = a jiSince {v i, v j } = {v j, v i }, matrix A is symmetric about the diagonal. That is, a ij = a ji All of the entries on the diagonal are zero. That is, a ii = 0 for 1 i nAll of the entries on the diagonal are zero. That is, a ii = 0 for 1 i n
23
23 Representation > Adjacency Matrix... Complexity Since the adjacency matrix has |V| 2 entries, the amount of spaced needed to represent the edges of a graph is O( |V| 2 ) regardless of the actual number of edges in the graph.Since the adjacency matrix has |V| 2 entries, the amount of spaced needed to represent the edges of a graph is O( |V| 2 ) regardless of the actual number of edges in the graph. If |E| << |V| 2 then most of the entries are 0If |E| << |V| 2 then most of the entries are 0 Wasteful representation !Wasteful representation !
24
24 Representation > Adjacency Matrix... Sparse and Dense Graphs Definition A sparse graph is a graph G = (V, E) in which |E| = O( |V| ) Definition A dense graph is a graph G = (V, E) in which |E| = ( |V| 2 )
25
25 Representation > Adjacency Matrix... Adjacency Lists
26
26 Representation Comparison of Representations operationadjacency matrixadjacency list find edge (v,w)O(1)O( |A(v)| ) enumerate all edges O( |V| 2 )O( |V| + |E| ) enumerate edges emanating from v O( |V| )O( |A(v)| ) enumerate edges incident on w O( |V| )O( |V| + |E| )
27
27Implementation(*)
28
28 Implementation (*) Vertex import java.util.Enumeration; public interface Vertex extends Comparable { int getNumber(); Object getWeight(); Enumeration getIncidentEdges(); Enumeration getEmanatingEdges(); Enumeration getPredecessors(); Enumeration getSuccessors(); }
29
29 Implementation (*) Edge public interface Edge extends Comparable { Vertex getV0(); Vertex getV1(); Object getWeight(); boolean isDirected(); Vertex getMate(Vertex vertex); }
30
30 Implementation (*) Graph import java.util.Enumeration; public interface Graph extends Container { int getNumberOfEdges(); int getNumberOfVertices(); boolean isDirected(); void addVertex(int v); void addVertex(int v, Object weight); Vertex getVertex(int v); void addEdge(int v, int w); void addEdge(int v, int w, Object weight); Edge getEdge(int v, int w); boolean isEdge(int v, int w); boolean isConnected(); boolean isCyclic(); Enumeration getVertices(); Enumeration getEdges(); void depthFirstTraversal(PrePostVisitor visitor, int start); void breadthFirstTraversal(Visitor visitor, int start); }
31
31 Implementation (*) Directed Graph public interface Digraph extends Graph { boolean isStronglyConnected(); void topologicalOrderTraversal(Visitor visitor); }
32
32 Graph Traversal
33
33 Graph Traversal Depth-First Traversal similar to depth-first tree traversalsimilar to depth-first tree traversal because there is not root, we must specify a starting nodebecause there is not root, we must specify a starting node because a graph may be cyclic, we must prevent infinite recursionbecause a graph may be cyclic, we must prevent infinite recursion
34
34 Graph Traversal Depth-First Traversal... The depth-first traversal visits the nodes in the order c, a, b, d Remark A depth-first traversal only follows edges that lead to unvisited vertices.A depth-first traversal only follows edges that lead to unvisited vertices. if we omit the edges that are not followed, the remaining edges form a tree.if we omit the edges that are not followed, the remaining edges form a tree. The depth-first traversal of this tree is equivalent to the depth-first traversal of the graphThe depth-first traversal of this tree is equivalent to the depth-first traversal of the graph
35
35 Graph Traversal > Depth-First Traversal... Implementation (*) public abstract class AbstractGraph extends AbstractContainer implements Graph {... public void depthFirstTraversal(PrePostVisitor prepostvisitor, int i) { boolean aflag[] = new boolean[numberOfVertices]; for (int j = 0; j < numberOfVertices; j++) aflag[j] = false; depthFirstTraversal(prepostvisitor, vertex[i], aflag); } private void depthFirstTraversal( PrePostVisitor prepostvisitor, Vertex vertex1, boolean aflag[]) { if (prepostvisitor.isDone()) return; prepostvisitor.preVisit(vertex1); aflag[vertex1.getNumber()] = true; for (Enumeration enumeration = vertex1.getSuccessors(); enumeration.hasMoreElements(); ) { Vertex vertex2 = (Vertex) enumeration.nextElement(); if (!aflag[vertex2.getNumber()]) depthFirstTraversal(prepostvisitor, vertex2, aflag); } prepostvisitor.postVisit(vertex1); }
36
36 Graph Traversal Breadth-First Traversal similar to breadth-first tree traversalsimilar to breadth-first tree traversal uses a queue of verticesuses a queue of vertices because there is not root, we must specify a starting nodebecause there is not root, we must specify a starting node because a graph may be cyclic, we must ensure that a vertex is enqueued only oncebecause a graph may be cyclic, we must ensure that a vertex is enqueued only once
37
37 Graph Traversal Breadth-First Traversal... The breadth-first traversal visits the nodes in the order a, b, c, d
38
38 Graph Traversal > Breadth-First Traversal... Implementation(*) public abstract class AbstractGraph extends AbstractContainer implements Graph {... public void breadthFirstTraversal(Visitor visitor, int i) { boolean aflag[] = new boolean[numberOfVertices]; for (int j = 0; j < numberOfVertices; j++) aflag[j] = false; QueueAsLinkedList queueaslinkedlist = new QueueAsLinkedList(); aflag[i] = true; queueaslinkedlist.enqueue(vertex[i]); while (!queueaslinkedlist.isEmpty() && !visitor.isDone()) { Vertex vertex1 = (Vertex) queueaslinkedlist.dequeue(); visitor.visit(vertex1); for (Enumeration enumeration = vertex1.getSuccessors(); enumeration.hasMoreElements(); ) { Vertex vertex2 = (Vertex) enumeration.nextElement(); if (!aflag[vertex2.getNumber()]) { aflag[vertex2.getNumber()] = true; queueaslinkedlist.enqueue(vertex2); }... }
39
39 Graph Traversal Topological Sort Definition Consider a DAG with G = (V, E). A topological sort of the vertices of G is a sequence S = { v 1, v 2,..., v |V| } in which each element of V appears exactly once. For every pair of distinct vertices v i and v j in the sequence S, if v i v j is an edge in G, i.e., (v i, v j ) E, then i < j.Definition Consider a DAG with G = (V, E). A topological sort of the vertices of G is a sequence S = { v 1, v 2,..., v |V| } in which each element of V appears exactly once. For every pair of distinct vertices v i and v j in the sequence S, if v i v j is an edge in G, i.e., (v i, v j ) E, then i < j.
40
40 Graph Traversal Topological Order Traversal a traversal that visits the vertices of a DAG in the order given by the topological sorta traversal that visits the vertices of a DAG in the order given by the topological sort compute the in-degrees of the verticescompute the in-degrees of the vertices repeatedly select a vertex with zero in-degree, visit it, and then “remove it from the graph”repeatedly select a vertex with zero in-degree, visit it, and then “remove it from the graph” S 1 = { a, b, c, d, e, f, g, h, i } S 2 = { a, c, b, f, e, d, h, g, i } S 3 = { a, b, d, e, g, c, f, h, i }... There are many
41
41 Is it connectedIs it connected Is there any cyclesIs there any cycles Graph Traversal Applications 1 0 2 3 9 4 8 7 5 6 7
42
42 Graph Traversal > Applications Connectedness Definition An undirected graph G = (V, E) is connected if there is a path in G between every pair of vertices in V. The connected sub-graphs of a graph are called connected components.
43
43 Graph Traversal > Applications Connectedness Definition A directed graph G = (V, E) is strongly connected if there is a path in G between every pair of vertices in V. Definition A directed graph G = (V, E) is weakly connected if the underlying undirected graph Ğ is connected.
44
44 Graph Traversal > Applications Connectedness Algorithm For all vertices Start from each vertex Start from each vertex Traverse the graph Traverse the graph Mark every visited vertex Mark every visited vertex If there is an unvisited vertex, unconnected If there is an unvisited vertex, unconnected
45
45 Graph Traversal > Applications Cycle Algorithm Apply topological-order traversal
46
46 Shortest Path HW: Find the shortest-path from your hometown to any other city in Turkiye employ at least three different techniques, and find the run time complexity using http://java.com/en/download/index.jsp Use the excel chart below for city-distances http://www.kgm.gov.tr/ http://java.com/en/download/index.jsp http://www.kgm.gov.tr/ http://java.com/en/download/index.jsp http://www.kgm.gov.tr/ http://www.unf.edu/~wkloster/foundations/DijkstraApplet/DijkstraApplet.htm
47
47 Shortest Path Distance Distance between two verticesDistance between two vertices –2-9 –3-9 –7-4 1 0 2 3 9 4 8 7 5 6 7
48
48 Shortest Path Weighted Path Length Definition Consider an edge-weighted graph G = (V, E). Let C(v i,v j ) be the weight on the edge connecting v i to v j. A path in G is a non-empty sequence of vertices P = {v 1, v 2,..., v k }. The weighted path length of path P is given by
49
49 Shortest Path Single-source shortest path Definition Single-source shortest path problem Given an edge-weighted graph G = (V, E) and a vertex v s V, find the shortest weighted path from v s to every other vertex in V. Remark If all weights are positive, it is well-defined.
50
50 if the graph is acyclic, the problem is easyif the graph is acyclic, the problem is easy –do a topological order traversal as long as all the edge weights are non- negative the shortest-path problem is well definedas long as all the edge weights are non- negative the shortest-path problem is well defined –a greedy algorithm works (Dijkstra's algorithm) Shortest Path Special Cases non-negative weights
51
51 if the graph has negative weights (but not negative cost cycles) a solution exists but the greedy algorithm does not workif the graph has negative weights (but not negative cost cycles) a solution exists but the greedy algorithm does not work if the graph has a negative cost cycle, no solution existsif the graph has a negative cost cycle, no solution exists Shortest Path Special Cases negative weights
52
52 Shortest Path Dijkstra’s Algorithm k v indicates that the shortest path to vertex v is known. Initially false d v the length of the shortest known path from v s to v. Initially . p v The predecessor of vertex v on the shortest path from v s to v. Initially unknown.
53
53 Shortest Path Dijkstra’s Algorithm 1.From the set of vertices for with k v =false, select the vertex v having the smallest tentative distance d v. 2.Set k v =true 3.For each vertex w adjacent to v for which k v true, test whether the tentative distance d v is greater than d v +c(v,w). If it is, set d v d v +c(v,w) and set p v v. In each pass exactly one vertex has its k v set to true. The algorithm terminates after |V|passes are completed at which time all the shortest paths are known.
54
54 Shortest Path : Dijkstra’s Algorithm http://www.lupinho.de/gishur/html/DijkstraApplet.html
55
55 Shortest Path All-pairs source shortest path Definition All-pairs source shortest path problem Given an edge-weighted graph G = (V, E), for each pair of vertices in V find the length of the shortest weighted path between the two vertices. Given an edge-weighted graph G = (V, E), for each pair of vertices in V find the length of the shortest weighted path between the two vertices.
56
56 Shortest Path with Floyd’s Algorithm The idea: Determine whether a path going from Vi to Vj via Vk is shorter than the best-known path from Vi to Vk. The idea: Determine whether a path going from Vi to Vj via Vk is shorter than the best-known path from Vi to Vk. V k the first k vertices in V P k (v,w) the shortest path from vertex v to w that passes only through vertices in V k D k (v,w) the length of path P k (v;w)
57
57 Shortest Path : Floyd’s Algorithm D 0 (v,w) is the adjacency matrix compute the sequence of matrices D 0, D 1,..., D |V| obtain the distances in D i+1 from those in D i by considering only the paths that pass through vertex v i+1 : D i+1 (v;w) = min{ D i (v, v i+1 )+D i (v i+1, w);D i (v,w)} D i+1 (v;w) = min{ D i (v, v i+1 )+D i (v i+1, w);D i (v,w)} HWLA1: Search, Floyds algorithm with O (V^3) HWLA2: Read, http://www-unix.mcs.anl.gov/dbpp/text/node35.html
58
58 Minimum Cost Spanning Trees
59
59 Minimum Cost Spanning Trees Spanning Tree Definition Consider a connected, undirected graph G=(V, E). A spanning tree T = (V’, E’) of G is a subgraph of G with the following properties: 1.V’ = V 2.T is connected 3.T is acyclic Remark Spanning tree is a tree.
60
60 Minimum Cost Spanning Trees Total Cost Definition The total cost of an edge-weighted undirected graph is the sum of the weights on all the edges in that graph
61
61 Minimum Cost Spanning Trees Minimum Spanning Tree Definition Consider an edge-weighted, undirected, connected graph G=(V, E), where c(v, w) represents the weight on edge {v, w} E. The minimum spanning tree of G is the spanning tree T=(V, E’) that has the smallest total cost, (a simple idea: remove the edges with large weights without loosing connection)
62
62 Minimum Cost Spanning Trees: Prim is a minor variation of Dijkstra's algorithm for shortest path constructs the minimum-cost spanning tree of a graph by selecting edges from the graph one- by-one and adding those edges to the spanning tree at each step, select an edge with the smallest edge weight that connects the tree to a vertex not yet in the tree
63
63 Minimum Cost Spanning Trees Prim’s Algorithm
64
64 Minimum Cost Spanning Tree: Kruskal is another greedy based approach that continually selects the edges in order of smallest weight without causing a cycle. Simple idea: Kruskal maintans a forest-a collection of trees. – –Select the smallest weights first to establish forests (set of smaller trees) – –Merge them at the end. Worst case running time: O(|E| Log|E|) which is dominated by heap operations. Note: since |E|=|V|^2, O(|E| Log|V|) Ex: Solve Figure 9.48 using Kruskal’s algorithmEx: Solve Figure 9.48 using Kruskal’s algorithm http://students.ceid.upatras.gr/~papagel/minKrusk.htm http://www-b2.is.tokushima-u.ac.jp/~ikeda/suuri/main/index.shtml
65
65 Critical Path Analysis(*) http://www.mindtools.com/critpath.html
66
66 Eg. Satellite Systems Engineering Communication Network Architectural Candidate Options Orbit: LEO/MEO/GEO Modulation/Coding Payload: Processing/ Non- Processing Antenna: Global/Spot beam Multiple Access: FDMA/TDMA/CDMA DAMA Switching: Circuit/ATM/Packet IntServ/DiffServ/MPLS Frequency Band: Ku/Ka/Q/V Transport: TCP/UDP Applications QoS Requirements Guaranteed Bandwidth BER CLR, CER, CDV IPLR, IPER, IPDV, IPTD End-to-End Delay Delay Variation Reliability … Systems Engineering Analysis Content Distribution Broadband Access Streaming Video Internet Applications Distributions Global Regional Operational Concept System Performance System Implementation Baseline Architecture Output Products Evaluation/ Analysis Preferred Network Design Traffic Require- ments Applications Business Plan System Cost / Implement. Complexity Output Products Trends Analysis of SatComNets End-to-end QoS TCP over S.ATM S.IP – Security, Multicast Satellite ATM QoS Buffer Requirements TCP Analysis Bandwidth Allocation Satellite IP QoS QoS Architecture TCP/UDP with DiffServ MPLS over Satellite Satellite Internet Access MF-TDMA vs. DOCSIS Spread ALOHA-Return Channel
67
67 Critical Path Analysis(*) http://www.mindtools.com/critpath.html
68
68 Critical Path Analysis Activity-Node Graphs represent a set of activities and scheduling constraints using a graphrepresent a set of activities and scheduling constraints using a graph each vertex represents an activityeach vertex represents an activity the weight on the vertex represents the time required to complete the activitythe weight on the vertex represents the time required to complete the activity directed edges represent the sequencing constraintsdirected edges represent the sequencing constraints the graph must be acyclicthe graph must be acyclic
69
69 Critical Path Analysis Critical path analysis Questions What is the minimum amount of time needed to complete all activities?What is the minimum amount of time needed to complete all activities? For a given activity v, is it possible to delay the completion of that activity without affecting the overall completion time?For a given activity v, is it possible to delay the completion of that activity without affecting the overall completion time? If yes, by how much can the completion of activity v be delayed?If yes, by how much can the completion of activity v be delayed?
70
70 Critical Path Analysis Event-Node Graphs edges represent the activitiesedges represent the activities weights on edges represent the time required for the activitiesweights on edges represent the time required for the activities vertices represent the commencement and termination of activities i.e., eventsvertices represent the commencement and termination of activities i.e., events
71
71 Critical Path Analysis Earliest and Latest Event Times E v the earliest time at which event v can occur L v the latest time at which event v can occur
72
72 Critical Path Analysis Slack Time consider an activity represented by edge (v, w)consider an activity represented by edge (v, w) the amount of time available for the activity is L w - E vthe amount of time available for the activity is L w - E v the time required for that activity is c(v, w)the time required for that activity is c(v, w) the slack time for activity (v, w) is S(v,w) = L w - E v - c(v, w)the slack time for activity (v, w) is S(v,w) = L w - E v - c(v, w)
73
73 Critical Path Analysis Critical Activity and Path Definition An activity with zero slack is critical Definition A critical path is a path from the initial vertex to the final vertex comprised solely of critical activities
74
74 Critical Path Analysis Example
75
75Summary GraphGraph –Directed Graph –Undirected Graph –Representation –Implementation Graph TraversalGraph Traversal Shortest PathShortest Path Minimum Cost Spanning TreesMinimum Cost Spanning Trees Critical Path AnalysisCritical Path Analysis HW: 1, 5, 6, 7, 10, 11, 15, 16, 20, 21, 30
76
76References Introductory Graph Theory Chartrand Dover, 1977Introductory Graph Theory Chartrand Dover, 1977 Data Structures and Algorithms with Object-Oriented Design Patterns in Java Preiss http://www.brpreiss.com/books/opus5/Data Structures and Algorithms with Object-Oriented Design Patterns in Java Preiss http://www.brpreiss.com/books/opus5/ Data Structures and Algorithms with Object-Oriented Design Patters in C++ Preiss Wiley, 1999Data Structures and Algorithms with Object-Oriented Design Patters in C++ Preiss Wiley, 1999 Data Structures and Algorithm Analysis in Java Weiss Addison-Wesley, 1999Data Structures and Algorithm Analysis in Java Weiss Addison-Wesley, 1999
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.