+ All Categories
Home > Documents > Prims Algorithm.ppt

Prims Algorithm.ppt

Date post: 07-Jul-2018
Category:
Upload: humayun
View: 227 times
Download: 1 times
Share this document with a friend

of 8

Transcript
  • 8/19/2019 Prims Algorithm.ppt

    1/17

    Prim's Algorithm

    on minimum spanningtree 

    Submitted by:Humayon Tahir (22)

    M.Mudassar (56)

    M.Sanwal (23)Akif Malik (17)Hafiz sman Tahir (5!3)

    "#$ar%m#n% of &om$u%#r S'i#n'#

    ni#rsi%y of Sar*odha +ahor# &am$us.

    ,%h S#m#s%#r S#' A S#ssion- 21,/10

  • 8/19/2019 Prims Algorithm.ppt

    2/17

    What is Minimum Spanning Tree

    • Given a connected, undirected graph, a

    spanning tree of that graph is asubgraph which is a tree and connectsall the vertices together.

    • A single graph can have many dierent

    spanning trees.• A minimum spanning tree is then

    a spanning tree with weight lessthan or equal to the weight of 

    every other spanning tree.

  • 8/19/2019 Prims Algorithm.ppt

    3/17

    graph G

    Spanning Tree from Graph G

    2

    4

    1

    2

    3

    1

    4 5

    1

  • 8/19/2019 Prims Algorithm.ppt

    4/17

    Algorithm for finding

    Minimum Spanning Tree

    • The Prim's Algorithm

  • 8/19/2019 Prims Algorithm.ppt

    5/17

    About Prim’s AlgorithmTh# al*ori%hm was dis'o#r#d in 1!3 y

    ma%h#ma%i'ian o%#'h 4arnik and la%#r ind#$#nd#n%ly

     y 'om$u%#r s'i#n%is% o#r% &. rim in 1!57.

    Th# al*ori%hm 'on%inuously in'r#as#s %h# siz# of a

    %r## s%ar%in* wi%h a sin*l# #r%# un%il i% s$ans all %h#

    #r%i'#s.

     rim8s al*ori%hm is fas%#r on d#ns#

    *ra$hs.

    rim8s al*ori%hm runs in 9(n:n)

    ;u% %h# runnin* %im# 'an # r#du'#usin* a sim$l# inary h#a$ da%a s%ru'%ur#

    and an ada'#n'y lis% r#$r#s#n%a%ion

  • 8/19/2019 Prims Algorithm.ppt

    6/17

    • Prim's algorithm for finding a minimal spanningtree parallels closely the depth- and breadth-first

    traversal algorithms !"st as these algorithmsmaintained a closed list of nodes and the pathsleading to them# Prim's algorithm maintains aclosed list of nodes and the edges that lin$ them

    into the minimal spanning tree• %hereas the depth-first algorithm "sed a stac$

    as its data str"ct"re to maintain the list of opennodes and the breadth-first traversal "sed a

    &"e"e# Prim's "ses a priority &"e"e

  • 8/19/2019 Prims Algorithm.ppt

    7/17

  • 8/19/2019 Prims Algorithm.ppt

    8/17

    ets( At first )e declare an array named* closed list

     And consider the open list as a priority &"e"e

    )ith min-heap

     Adding a node and its edge to the closed list

    indicates that )e have fo"nd an edge that lin$sthe node into the minimal spanning

    tree As a node is added to the

    closed list# its s"ccessors

    +immediately ad,acent nodesare e.amined and added to a

    priority &"e"e of open nodes

  • 8/19/2019 Prims Algorithm.ppt

    9/17

    /pen ist* d0lose ist*

    Total Cost: 0

  • 8/19/2019 Prims Algorithm.ppt

    10/17

    /pen ist* a, f, e, b

    0lose ist* d

    Total Cost: 0

  • 8/19/2019 Prims Algorithm.ppt

    11/17

    /pen ist* f, e, b

    0lose ist* d, a

    Total Cost: 5

  • 8/19/2019 Prims Algorithm.ppt

    12/17

    /pen ist* b, e, g

    0lose ist* d, a, f 

    Total Cost: 11

  • 8/19/2019 Prims Algorithm.ppt

    13/17

    /pen ist* e, g, c

    0lose ist* d, a, f, b

    Total Cost: 18

  • 8/19/2019 Prims Algorithm.ppt

    14/17

    /pen ist* c, g

    0lose ist* d, a, f, b, e

    Total Cost: 25

  • 8/19/2019 Prims Algorithm.ppt

    15/17

    /pen ist* g

    0lose ist* d, a, f, b, e, c

    Total Cost: 30

  • 8/19/2019 Prims Algorithm.ppt

    16/17

    /pen ist*

    0lose ist* d, a, f, b, e, c

    Total Cost: 39

  • 8/19/2019 Prims Algorithm.ppt

    17/17

    Than$ yo" for being )ith "s(

    Any


Recommended