See the assignment turn-in page (last modified on 11 September 2001) for instructions on turning in your assignment.
node
name - create a node with the label name. Should
print an error message if a node with the label name already exists in the
graph. The new node does not have an edge to any other node in the graph.
edge
name1 name2 - create an edge between the node
with label name1 and the node with label name2; name1 need
not be different than name2. If an edge already exists between
name1 and name2, do nothing; if name1 or name2
don't exist, print an informative error message.
print
- print the nodes and edges in the current graph, with the
following format:
where name is a node's label and namei is the label of a node to
which name
has an edge. The information on each node should appear on one
line; every node should have its information printed. The list of connected
nodes should appear in alphabetical order from left to right, and the nodes
should be printed in alphabetical order.
undo
- Undo the effects of the most recent effective node
or
edge
command; print an error message if there is no effective command to
undo. The most recent effective command undone becomes an inactive command.
redo
- Redo the most recent inactive command (which can only be a
node
or edge
command); print an error message if there's no inactive
command to redo. The most recent inactive command redone becomes an effective
command.
Command input comes from standard-in; command output (if any) goes to standard-out; error output goes to standard-error. Each command fits on one line of input and each line of input contains at most one command.
Each node
or edge
command entered from the command-line deletes all
inactive commands.
A name is any maximal sequence of non-space characters. Case is not
significant in node labels; however node labels should be output with exactly
the same case is they were input in a node
command. For example, the
label ALPHA
is the same as the label alpha
; however, if the label
Alpha
was input, then the label Alpha
must be output. "Alphabetic
order" should be extended to include the whole ASCII collating sequence.
$ gm | |
* print | There's nothing to print. |
* node red | |
* print | |
red | |
* edge red white | |
no node with label "white". | |
* node white | |
* edge red white | |
* print | |
red white | |
white red | |
* undo | edge red white is the most recent effective command. |
* print | |
red | |
white | |
* undo | node white is the most recent effective command. |
* print | |
red | |
* undo | node red is the most recent effective command. |
* print | |
* undo | |
no commands to undo. | |
* redo | node red is the most recent inactive command. |
* print | |
red | |
* redo | redo node white |
* node blue | edge red white is gone. |
* redo | |
no commands to redo | |
* print | |
blue | |
red | |
white | |
*^D | |
$ |
This page last modified on 1 November 2001.