Advanced Programming I Lecture Notes

Advanced Programming I Lecture Notes

22 March 2007 • Graph Algorithms


Outline

Connectedness

Connected Graphs

Connectedness Algorithm

Articulation Points

Biconnectedness

Depth-First Searching

Recognizing Backedges

A Biconnectedness Algorithm

Spanning Trees

Spanning Tree Example

A Spanning-Tree Algorithm

Traversal Costs

Minimum Spanning Trees

Example Non-MST

Finding MSTs

An MST Algorithm

graph mst(graph g)
  min-queue minq
  vertex v = g.vertices().pick()
  for n in g.neighbors(v)
    minq.enq((v, n), g.weight(v, n))
  while not minq.empty()
    e = minq.deq()
    v = e.second()
    if not mst.vertices().member(v)
      mst.add_edge(e)
      for n in g.neighbors(v)
	if not mst.vertices().member(n)
	  minq.enq((v, n), g.weight(v, n))
  return mst

Example MST

MST Algorithm Properties

Path Weights

Finding Minimum Paths

Modified PFS

A Minimum-Path Algorithm

min-path(graph g, vertex v1) unsigned dist[g.vertices().size()] = { ∞ } min-queue minq for n in g.neighbors(v1) dist[n] = g.weight(v1, n) minq.enq((v1, n), g.weight(v1, n)) while not minq.empty() e = minq.deq() v = e.second if dist[v] > dist[e.first] + g.weight(e) dist[v] = dist[e.first] + g.weight(e) for n in g.neighbors(v) if not n mst.vertices().member(n) minq.enq((v,n),dist[v]+g.weight(v,n))

Min-Path Properties

Observations

PERT Charts

Directed Acyclic Graphs

Scheduling PERT Tasks

  • Depth-first search backtracks more coherently then does breath-first search.

    PERT-Schedule Algorithm

    Exploiting Independence

    Edge And Vertex Terms

    Producing Better Schedules

    Example Schedule

    Critical Paths

    Finding Critical Paths

    Points to Remember


    This page last modified on 29 March 2006.

    This work is covered by a
    Creative Commons License.