CLOSURE v1.50 - compute transitive closure |
Documentation revised 21 Oct 00 - Copyright (c) 1996-2000 by Rune Berg. TextTools Freeware. |
Contents:
Usage | Top || Next |
closure [log logfile] [option] key [graphfile] [to resultfile]
See Understanding The Usage Section for details.
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 fields in infile by character C (except \). Use \t to form a tab. |
-csvi | Do CSV (comma separated values) style parsing of input fields from infile. Unless the -iC option is given, use a comma as the field separator. |
-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.
closure handles max. 5000 graph nodes.
closure handles max. 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/missing command line arguments |
104 | Error opening file |
105 | I/O Error |
106 | Capacity overrun |
107 | File name clash |
For more details, see TextTools General Features.
Version History | Top || Previous |
These are the released versions of closure:
Version | Date | Changes |
---|---|---|
1.01 | 25-Feb-96 | n/a |
1.10 | 26-Sep-96 |
|
1.20 | 16-Feb-97 |
|
1.30 | 12-Jul-97 |
|
1.40 | 2-Jan-99 |
|
1.50 | 21-Oct-00 |
|
End of document |