graphpak.icn: Procedures for manipulating directed graphs

procedure read_graph:      read graph
procedure write_graph:     write graph
procedure closure:         transitive closure of graph

link graphpak
May 2, 2001; Ralph E. Griswold
This file is in the public domain.

The procedures here use sets to represent directed graphs.  See
The Icon Programming Language, second edition, pp. 195-198.

A value of type "graph" has two components: a list of nodes and
a two-way lookup table.  The nodes in turn contain pointers to
other nodes.  The two-way table maps a node to its name and
vice-versa.

Graph specifications are give in files in which the first line
is a white-space separated list of node names and subsequent lines
give the arcs, as in

     Tucson Phoenix Bisbee Douglas Flagstaff
     Tucson->Phoenix
     Tucson->Bisbee
     Bisbee->Bisbee
     Bisbee->Douglas
     Douglas->Phoenix
     Douglas->Tucson

Source code | Program Library Page | Icon Home Page