For Friday Read Weiss, chapter 9, section 6 No homework Program 3 - - PowerPoint PPT Presentation

for friday
SMART_READER_LITE
LIVE PREVIEW

For Friday Read Weiss, chapter 9, section 6 No homework Program 3 - - PowerPoint PPT Presentation

For Friday Read Weiss, chapter 9, section 6 No homework Program 3 due Program 3 Questions? Weighted Graphs Dykstras algorithm A greedy algorithm A form of best-first search Negative Weights Problem Network Flow


slide-1
SLIDE 1

For Friday

  • Read Weiss, chapter 9, section 6
  • No homework
  • Program 3 due
slide-2
SLIDE 2

Program 3

  • Questions?
slide-3
SLIDE 3

Weighted Graphs

  • Dykstra’s algorithm
  • A greedy algorithm
  • A form of best-first search
slide-4
SLIDE 4

Negative Weights Problem

slide-5
SLIDE 5

Network Flow

  • We have a weighted directed graph with a

source and a sink--a network.

  • Note that cycles are possible.
  • Each edge’s weight represent the maximum

possible flow through that edge.

  • We want to determine the maximum

possible flow through the network and a way to achieve that maximum.

slide-6
SLIDE 6

Ford-Fulkerson Method

  • Start with 0 flow in the network
  • Repeat

– Select a path from source to sink with no full forward edges or a non-full backward edge. – Increase flow by maximum possible amount on that path

  • Until no paths can be selected
  • You now have maximal flow
slide-7
SLIDE 7

Selecting a Path to Augment

  • If you select the longest path, problems can

arise.

  • If the shortest available path is used at every

iteration: the number of paths used before maximum flow is found is less than VE

  • Can be improved by using the path with the

best improvement to flow at each iteration.

slide-8
SLIDE 8

Critical Path

  • The longest path between two nodes
  • For what kind of graph is this meaningful?
  • Why would we want to compute it?
  • How could we compute it?
slide-9
SLIDE 9

Transitive Closure

  • The problem is: for each node in the graph,

what other nodes can be reached from that node?

  • Not an issue in an undirected graph. Why?
  • Can be done be doing a search from each

node and discovering all of the nodes that can be found from each node.

slide-10
SLIDE 10

Transitive Closure (cont.)

  • Depth First Search can be used to compute

the transitive closure of a graph represented with an adjacency list in O(V(V+E)) time.

  • DFS can be used to compute the transitive

closure of a graph represented with an adjacency matrix in O(V3) time.

slide-11
SLIDE 11

Warshall’s Algorithm

  • Note that if there is a path from X to Y and there

is a path from Y to Z, then there is a path from X to Z

  • for (y = 0; y < V; y++)

for (x = 0; x < V; x++) if (a[x][y]) for (j = 0; j < V; j++) if (a[y][j]) a[x][j] = 1;

slide-12
SLIDE 12

All Shortest Paths

  • In sparse matrix, just run Dykstra’s

algorithm for each vertex

  • In dense graphs, use a matrix and use an

algorithm similar to Warshall’s algorithm

  • Computes all shortest paths in O(V3) time
  • To determine actual path, need an additional

matrix.

slide-13
SLIDE 13

Floyd’s Algorithm

  • for (y = 0; y < V; y++)

for (x = 0; x < V; x++) if (a[x][y]) for (j = 0; j < V; j++) if (a[y][j] > 0) if (!a[x][j] || (a[x][y] + a[y][j] < a[x][j])) a[x][j] = a[x][y] + a[y][j];

slide-14
SLIDE 14

Minimum Spanning Tree

  • Useful to solve problems like: what’s the

cheapest way to connect a set of points to each other

  • Can be solved using a greedy algorithm
  • So we can use best-first search (search

using a priority queue)

  • Applies to undirected graphs
slide-15
SLIDE 15

Minimum Spanning Trees

  • Prim’s algorithm

Select a node to put in the spanning tree while some nodes are not in the tree select the shortest edge connecting a node in the tree to a node NOT in the tree add that edge and node to the tree end while

slide-16
SLIDE 16

Minimum Spanning Trees

  • Kruskal’s Algorithm

while not all nodes are in a single tree select the shortest edge with at least one end node not currently in a tree or connecting to trees to each other add that edge and its end nodes to the tree end while

slide-17
SLIDE 17

Graph Searching

  • Depth-first
  • Breadth-first
  • Best-first
slide-18
SLIDE 18

Applications of Searching

  • Connectivity in an undirected graph
slide-19
SLIDE 19

Bi-Connectivity

slide-20
SLIDE 20

Euler Circuits