Sei sulla pagina 1di 32

BY: GHULAM ABBAS MS-III(CCN) SUKKUR IBA

Topics
Definitions & Networking Basics
MST Algorithms Kruskal Reverse Delete Prim Brief History Importance

Definitions & Networking Basics

Network models are created from two major building blocks:


arcs (sometimes called edges), which are connecting lines, and nodes, which are the connecting points for the arcs. A graph is a structure that is built by interconnecting nodes and arcs. A directed graph (often called a digraph) is a graph in which the arcs have specified directions, as shown by arrowheads. Finally, a network is a graph (or more commonly a digraph) in which the arcs have an associated flow.

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Networking Basics

A network is an arrangement of paths connected at various points, through which items move.
Introduction to Management Science, 9th ed, Bernard W. Taylor III, 2006

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Definitions & Networking Basics Some further definitions associated with graphs and networks:
chain: a sequence of arcs connecting two nodes i and j. For example, in Figure 8.1(a), we might connect nodes A and E via the chains ABCE or ADCE. path: a sequence of directed arcs connecting two nodes. In this case, you must respect the arc directions. For example, in Figure 8.1(b), a path from A to E might be ABDE, but the chain ABCE is not a path because it traverses arc BC in the wrong direction. cycle: a chain that connects a node to itself without any retracing.

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Definitions & Networking Basics connected graph (or connected network): has
just one part. In other words you can reach any node in the graph or network via a chain from any other node.

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

tree: a connected graph having no cycles. Some examples are shown in Figure 8.2(a).

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Definitions
spanning tree: normally a tree selected from among the arcs in a graph or network so that all of the nodes in the tree are connected.

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Definitions
flow capacity: an upper (and sometimes lower) limit on the amount of flow in an arc in a network. For example, the maximum flow rate of water in a pipe, or the maximum simultaneous number of calls on a telephone connection. source (or source node): a node which introduces flow into a network. This happens at the boundary between the network under study and the external world. sink (or sink node): a node which removes flow from a network. This happens at the boundary between the network under study and the external world.

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

The Minimum Spanning Tree Problem


Given a graph in which the arcs are labeled with the distances between the nodes that they connect, find a spanning tree which has the minimum total length.

NO CYCLES ALLOWED!! ALGORITHMS a problem solving procedure following a set of rules Cycle- the nodes are connected by more than one edge.
Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

Steps of the minimal spanning tree solution method:


Select any starting node (conventionally, node 1 is selected). 2. Select the node closest to the starting node to join the spanning tree. 3. Select the closest node not presently in the spanning tree. 4. Repeat step 3 until all nodes have joined the spanning tree.
1.

Introduction to Management Science, 9th ed, Bernard W. Taylor III, 2006

Practical Optimization: A Gentle Introduction, John W. Chinneck, 2010 http://www.sce.carleton.ca/faculty/chinneck/po.html

What is an MST Algorithm An MST algorithm is a way to show the


shortest distance There are many different algorithms:

Kruskal

Reverse Delete
Prim

Introduction to Management Science, 9th ed, Bernard W. Taylor III, 2006

KRUSKALS ALGORITHM
Pick out the smallest edges 2. Repeat Step 1 as long as the edges selected does not create a cycle 3. When all nodes have been connected, you are done
1.

http://www.slideshare.net/zhaokatherine/minimum-spanning-tree

REVERSE-DELETE ALGORITHM
This is the opposite of Kruskals algorithm 1. Start with all edges 2. Delete the longest edge 3. Continue deleting longest edges as long as all nodes are connected and no cycles are formed

http://www.slideshare.net/zhaokatherine/minimum-spanning-tree

PRIMS ALGORITHM
Pick out a node 2. Pick out the shortest edge that is connected to your tree so far, as long as it doesnt create a cycle 3. Continue this until all nodes are covered
1.

http://www.slideshare.net/zhaokatherine/minimum-spanning-tree

The execution of Kruskal's algorithm


The edges are considered by the algorithm in sorted order by weight.

The edge under consideration at each step is shown with a red weight number.
8 4 7

b
11 7

c
2

d
14

a
8

e
10

17

8 4

b
11 7
2

c i
4

d
14

a
8

e
10

8 4

b
11 7 2

c i
4

d
14

a
8

e
10

18

8 4

b
11 7 2

c i
4

d
14

a
8

e
10

8 4

b
11
7 2

c i
4

d
14

a
8

e
10

f
19

8 4

b
11 7 2

c i
4

d
14

a
8

e
10

8 4

b
11 7 2

c
i
4

d
14

a
8

e
10

20

8
4

b
11 7 2

c i
4

d
14

a
8

e
10

8 4

b
11 7 2

c
i
4

d
14

a
8

e
10

21

8 4

b
11 7 2

c i
4

d
14

a
8

e
10

8 4

b
11 7 2

c
i
4

d
14

a
8

e
10

22

Grow the minimum spanning tree from the root vertex r. Q is a priority queue, holding all vertices that are not in the tree now.

key[v] is the minimum weight of any edge connecting v to a vertex in the tree.
parent[v] names the parent of v in the tree.

When the algorithm terminates, Q is empty; the minimum spanning tree A for G is thus A={(v,parent[v]):vV-{r}}. Running time: O(||E||lg |V|).

23

The execution of Prim's algorithm(moderate


part)
the root vertex
8 4 7

b
11
7 2

c i
4

d
14

a
8

e
10

1 8

2 7

b
11 7

c
2

d
4 14

a
8

e
10

f
24

8 4

b
11 7

c
2

d
4 14

a
8

e
10

1 8

2 7

b
11 7 2

c
i
4

d
14

a
8

e
10

25

8
4

b
11 7

c
2

d
4 14

a
8

e
10

8 4

b
11 7 2

c
i
4

d
14

a
8

e
10

26

8 4

b
11 7

c
2

d
4 14

a
8

e
10

8 4

b
11 7

c
2

d
4 14

a
8

e
10

27

8 4

b
11 7 2

d
14

a
8

e
10

Bottleneck spanning tree: A spanning tree of G whose largest edge weight is minimum over all spanning trees of G. The value of the bottleneck spanning tree is the weight of the maximum-weight edge in T.
Theorem: A minimum spanning tree is also a bottleneck spanning tree. (Challenge problem)
28

MSTs
Kruskal (1956) and Prim (1957) MSTs makes our life easier and we save money by using short paths MSTs was first seen in Poland, France, the Czech Republic Slovakia, and Czechoslovakia

IMPORTANCE OF MSTS
We need it in computer science because it prevent loops in a switched network with redundant paths 2. It is one of the oldest and most basic graphs in theoritical computer science
1.

http://www.slideshare.net/zhaokatherine/minimum-spanning-tree

Why we like MSTs 1. MSTs are fun to work with


2. It helps us find the shortest route

The shortest distance between two people is a

sMILE.

THANKS FOR PATIENCE

Potrebbero piacerti anche