`posets/text/filter` := TEXT(
` `,
`FUNCTION:  filter - filtration of a poset (or directed graph)`,
` `,
`CALLING SEQUENCE:  filter(P);  `,
`                   filter(P,X);`,
`                   filter(P,n);`,
` `,
`PARAMETERS:  P = a poset (or more generally, an acyclic digraph)`,
`             X = a set (the vertex set)`,
`             n = a positive integer (the number of vertices)`,
`   `,
`SYNOPSIS:`,
`  The filtration of a poset P is an ordered partition [F_1,...,F_r] of`,
`  the vertex set of P defined recursively as follows: F_1 is the set of`,
`  minimal elements of P, and [F_2,...,F_r] is the filtration of P - F_1.`,
`   `,
`  filter(P,X) returns the filtration of a poset P with vertex set X.`,
`  filter(P,n) does the same, if the vertex set of P is {1,...,n}.`,
`  filter(P) does the same, assuming that P has no isolated vertices.`,
`   `,
`  Note that map(op,filter(P,X)) is a linear extension of P.`,
`   `,
`  More generally, if D is a directed graph with vertex set X and F_1 is`,
`  the set of vertices of D with out-degree 0, then filter(D,X) returns`,
`  either [] (if F_1 is empty) or [F_1,F_2,...,F_r] (if F_1 is nonempty),`,
`  where [F_2,...,F_r] is the filtration of D - F_1.`,
`   `,
`  Note that D is acyclic if and only if every vertex of D occurs in the`,
`  filtration of D.`,
`   `,
`  The algorithm is based on a variation of topological sort.`,
`  See Knuth, TAOCP Volume I, Section 2.2.3.`,
`   `,
`EXAMPLES:`,
`  filter(J({},3));                yields      [{1}, {2,3,5}, {4,6,7}, {8}]`,
`  filter({[a,b],[b,e],[c,e]},{a,b,c,d,e});`,
`                                  yields           [{a,c,d}, {b}, {e}]`,
` `,
`SEE ALSO:  extensions, ranked, strongcomps`,
NULL):

if `+`(0)=0 then # Maple V.4 or later
  print(INTERFACE_HELP(insert, topic=`posets/filter`,
  helpfile=HomeLib, text=`posets/text/filter`))
elif ceil(0)=0 then # Maple V.2 or V.3
  `help/posets/text/filter`:=`posets/text/filter`:
  save `help/posets/text/filter`, cat(HomeLib,`/help/posets/text/filter.m`)
fi:
