CLOSURE v1.40 - compute transitive closure |
Revised 2-Jan-99. Copyright (c) 1996-99 by Rune Berg. TextTools Freeware. |
Usage | Description | Example | Options | Limitations | Return Codes | Version History | tt_r6
Usage | Top | Next |
closure [log logfile] [option] key [graphfile] [to resultfile]
Description | Top | Previous | Next |
closure builds a directed graph of strings from the contents of graphfile, computes the set of strings belonging to the transitive closure starting at key, and writes that set to resultfile.
key is a string.
graphfile is an ASCII text file containing lines with (by default, but see -i option) whitespace-separated fields; this is described in more detail in the documentation for tcols. Each such field is considered a 'string' in this discussion.
For each line with strings S1 S2 ... SN in graphfile, closure adds nodes S1 S2 ... SN, and edges S1->S2 ... S1->SN, to the directed graph.
For each line with just one string S1 in graphfile, closure adds a node S1 (but no edges) to the directed graph.
closure ignores empty (whitespace only) lines in graphfile.
closure ensures the directed graph never contains duplicate nodes or edges.
If key is a string equal one of the strings in graphfile, then closure writes, to resultfile, one string per line: key and all strings reachable by following paths of edges from key's node.
If key does not appear in graphfile, then closure writes nothing to resultfile.
closure does not write duplicate strings.
If key is not equal to any of the strings in graphfile, resultfile will be empty.
If you don't specify graphfile, closure reads from standard input.
If you don't specify resultfile, closure writes to standard output.
If you don't specify logfile, closure writes error messages to standard
error.
Example | Top | Previous | Next |
As an example, consider the (zoologically rather dubious) graphfile "fauna.txt":
animal dog horse bird fish horse pony bird sparrow eagle penguin fish whale shark shark hammerhead great-white
For the command:
closure fish fauna.txt
closure builds (internally) the graph:
animal |--> dog |--> horse | +--> pony |--> bird | |--> sparrow | |--> eagle | +--> penguin +--> fish |--> whale | |--> hammerhead | +--> great-white +--> shark
and writes as result (though not necessarily in this order):
fish whale shark hammerhead great-white
Options | Top | Previous | Next |
closure recognizes the following command line options:
Option | Function |
---|---|
-iC | Separate input fields by character C (except \). Use \t to form a tab. |
-r | Print internal table and hashing statistics. |
-v | Print version banner and usage info to standard error (or logfile, if given), then exit. |
Limitations | Top | Previous | Next |
See TextTools General Features for max. input line length and max. fields per line.
When using the -i option, make sure that graphfile does not have unwanted spaces at the end of lines - closure regards trailing spaces as part of the last field.
DOS:
closure cannot handle more than 1000 graph nodes.
closure cannot handle more than 4000 graph edges.
Win32 console mode:
closure cannot handle more than 5000 graph nodes.
closure cannot handle more than 20000 graph edges.
Graph string data is limited only by available memory.
Return Codes | Top | Previous | Next |
closure returns with one of the following codes ("error levels"):
Code | Meaning |
---|---|
0 | Success |
2 | key not found in graphfile (warning) |
101 | Out of memory |
102 | Incorrect command line arguments |
104 | Error opening file |
105 | I/O error |
106 | Capacity overrun |
107 | File name clash |
Version History | Top | Previous |
These are the released versions:
Version | Date | Changes |
---|---|---|
1.01 | 25-Feb-96 | n/a |
1.10 | 26-Sep-96 | * Very minor changes. |
1.20 | 16-Feb-97 | * New option: -r * Increased capacity. * Now available as Win32 version. * Bug-fix: would print a newline when key was not found. |
1.30 | 12-Jul-97 | * Now gives proper return codes. |
1.40 | 2-Jan-99 | * Win32 version has increased max. input line length / fields per line. * Win32 version now prints coloured response texts. |
End of document |