EE 608 Project 1

Write a C program that reads a text file, where the first line is the number of nodes N, the second line is the number of bidirectional links L, and the next L lines are for each link, and has the two end nodes, and a "cost" associated with the link. We assume that the nodes are numbered 0, 1, ...., N-1, and the link costs are real valued. The following is an example where the number of nodes N = 5 and the number of links L = 7.
5
7
0  1  1
2  0  2
1  2  3
1  3  1
3  2  2
2  4  3
4  3  2
You can download the example by clicking here.

Note that a link (u,v) between nodes u and v can also be written (v,u).

Your program should, for each node x, compute the number of links incident to it and the sum of the costs of those links. For example, in the example above, node 0 has two links incident to it (one connected to node 1 and the other connected to node 2), and the sum of the costs of those links is 3. The following is the output for the above example:

0  2  3
1  3  5
2  4 10
3  3  5
4  2  5

Your program should run on spectra.

Submit by email to me (galens@hawaii.edu) on March 23, 2007 a gzipped tar'd directory that includes


Information about tar (UNIX systems also have a manual on tar, which you can access by typing "man tar")

To tar a directory "DIR" and to name the tar'd file "x.tar":

     tar cvf x.tar DIR

To untar:

     tar xvf x.tar
and the director DIR is restored.