HW - Graphs I

1 Theory

  1. 6.6
  2. 7.1
  3. 7.2
  4. 7.3 a, b, d

    For part d, just supply a breadth-first spanning tree, starting at i) a, and at ii) d Assume that the adjacency function returns vertices in lexical order.

2 Implementation

  1. (Makefile target: prob1) Implement Floyd's all-pairs shortest-path algorithm.

    You may assume the node labels are the ordinal numbers [0..(n-1)].

    You will output the distance matrix, and the predecessor matrix. Just use simple text formatting to get the columns pretty much lined up, and use single-spacing. Use INF for infinity. Here are some examples in Python.

    You may use my graph representation, and build the matrix yourself, or you may write your own adjacency matrix representation (note, the work is about the same here). However it works, your program will read an undirected graph from standard input, in the same format (essentially an adjacency list) as my graph reads. ~kschmidt/public_html/CS260/Programs/Graphs/example.input is an example.

    Note that this graph is undirected, so if you add edge (u, v) to the graph, then you should also add (v, u) to the graph, w/the same weight.

  2. (Makefile target: view) Display the code containing the algorithm in a pager.