Marcel Grünauer == hanekomu (跳ね込む) > Algorithm-EquivalenceSets-0.03 > Algorithm::EquivalenceSets

Download:
Algorithm-EquivalenceSets-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.03   Source  

NAME ^

Algorithm::EquivalenceSets - Group sets transitively

SYNOPSIS ^

    use Algorithm::EquivalenceSets;

    my @sets = (
        [ 'a', 1, 2 ],
        [ 'b', 3, 4 ],
        [ 'c', 5    ],
        [ 'd', 1, 6 ],
        [ 'e', 3, 6 ],
        [ 'f', 5, 7 ],
    );

    my @equiv_sets = equivalence_sets(@sets);

    # @equiv_sets is ([ qw(c f 5 7) ], [ qw(a b d e 1 2 3 4 6) ])

DESCRIPTION ^

This module exports one function, equivalence_sets(), which takes a list of sets and returns another list of sets whose contents are transitively grouped from the input sets.

Imagine the input sets to be [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] and [ 1, 3, 7 ]. The returned sets would be [ 1, 2, 3, 4, 7 ] and [ 5, 6 ], because [ 1, 2 ] and [ 3, 4 ] are tied together by [ 1, 3, 7 ], but [ 5, 6 ] stands on its own. So you could say the returned sets represent a kind of transitive union. (Real mathematicians may now flame me about the misuse of terminology.)

Each set is an array reference. The return sets are given as an array in list context, or as a reference to that array in scalar context.

BUGS AND LIMITATIONS ^

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

INSTALLATION ^

See perlmodinstall for information and options on installing Perl modules.

AVAILABILITY ^

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.

AUTHOR ^

Marcel Grünauer, <marcel@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright 2007 by Marcel Grünauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.