1 / 7

Minimum cost spanning tree and activity networks

Minimum cost spanning tree and activity networks. Data structure 2002/12/2. Minimum-cost spanning trees (MST) in a given graph (6.3). A minimum-cost spanning tree is a spanning tree of least cost Design strategy – greedy method Kruskal ’ s algorithm Edge by edge Prim ’ s algorithm

sydnee
Download Presentation

Minimum cost spanning tree and activity networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Minimum cost spanning tree and activity networks Data structure 2002/12/2

  2. Minimum-cost spanning trees (MST) in a given graph (6.3) • A minimum-cost spanning tree is a spanning tree of least cost • Design strategy – greedy method • Kruskal’s algorithm • Edge by edge • Prim’s algorithm • Span out from one vertex • Sollin’s algorithm • Hint: Construct from connected components • Leave as a homework

  3. An MST example 0 0 28 1 1 10 10 14 14 16 16 5 5 6 6 2 2 24 25 25 18 12 12 4 4 22 22 3 3

  4. Kruskal’s algorithm • Edge by edge • O(e log e) • Algorithm: T={}; While ((T contains less than n-1 edges) &&(E not empty)){ choose an edge (v,w) from E of lowest cost; delete (v,w) from E; if((v,w) does not create a cycle in T) add(v,w) to T; else discard(v,w); } If(T contains fewer than n – 1 edges) printf(“No spanning tree\n”);

  5. Prim’s algorithm • Begins from a vertex • O(n2) • Algorithm: T={}; TV = {0}; /* start with vertex 0 and no edges */ While (T contains fewer than n-1 edges){ let(u,v) be a least cost edge s.t. u in TV and v not in TV; if (there is no such edge) break; add v to TV; add (u,v) to T; } If (T contains fewer than n-1 edges) printf(“No spanning tree\n”);

  6. Activity networks (6.5) • Definition: • Vertex i is a predecessor of j • Iff there is a directed path from i to j • Vertex i is an immediate predecessor of j • Iff <i,j> is an edge in G • Successor, immediate successor • Precedence relation, is a partial order relation • Transitive • Irreflexive • Can be represented by a Directed Acyclic Graph (DAG)? • Topological order • is a linear ordering of the vertices of a graph s.t. if i is a predecessor of j, then i precedes j in the linear ordering

  7. An example of activity network Activity on Edge networks Activity on Vertex networks 7 2 資結 1 9 finish 2 start 5 6 9 計概 邏設 OS 1 4 7 1 3 8 4 組語 計結 5 4 4 6 A topological order: 計概,邏設,組語,計結,資結,OS 2 Earliest time Latest time Critical activites

More Related