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


UsageTop | Next

closure [log logfile] [option] key [graphfile] [to resultfile]


DescriptionTop | 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.


ExampleTop | 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


OptionsTop | Previous | Next

closure recognizes the following command line options:


LimitationsTop | 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:

Win32 console mode:

Graph string data is limited only by available memory.


Return CodesTop | Previous | Next

closure returns with one of the following codes ("error levels"):


Version HistoryTop | Previous

These are the released versions:

End of document