edu.ksu.cis.projects.bogor.util
Class Relation

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.util.Relation

public class Relation
extends Object

This class provides methods for working with relation/function.

Version:
CVS $Revision: 1.2 $ $Date: 2004/12/18 22:36:34 $
Author:
Robby

Constructor Summary
Relation()
           
 
Method Summary
static
<K> Map<K,Set<K>>
functionClosure(Map<K,K> fr, boolean sortedDomain, boolean sortedCoDomain)
          Builds a transitive closure of a function.
static
<K> Map<K,Set<K>>
functionInverse(Map<K,K> fr, boolean sortedDomain, boolean sortedCoDomain)
          Builds an inverse function or relation of a function.
static
<K> Map<K,Set<K>>
relationClosure(Map<K,Set<K>> fr, boolean sortedDomain, boolean sortedCoDomain)
          Builds a transitive closure of a relation.
static
<K> Map<K,Set<K>>
relationInverse(Map<K,Set<K>> fr, boolean sortedDomain, boolean sortedCoDomain)
          Builds an inverse function or relation of a relation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Relation

public Relation()
Method Detail

relationClosure

public static <K> Map<K,Set<K>> relationClosure(Map<K,Set<K>> fr,
                                                boolean sortedDomain,
                                                boolean sortedCoDomain)
Builds a transitive closure of a relation.

Parameters:
fr - The relation. Must be non-null. Each key and value must be non-null.
sortedDomain - Indicates that the resulting domain should be sorted. If true, then fr's domain is Comparable.
sortedCoDomain - Indicates that the resulting co-domain should be a sorted set. If true, then fr's co-domain is Set<Comparable>.
Returns:
The transitive closure of the relation. Non-null.
  • If sortedDomain and sortedCoDomain then TreeMap<Comparable, OrderedSet<Comparable>.
  • If sortedDomain then TreeMap<Comparable, Set<Object>.
  • If sortedCoDomain then Hashtable<Object, OrderedSet<Object>.
  • Else, Hashtable<Object, Set<Object>.

functionClosure

public static <K> Map<K,Set<K>> functionClosure(Map<K,K> fr,
                                                boolean sortedDomain,
                                                boolean sortedCoDomain)
Builds a transitive closure of a function.

Parameters:
fr - The function. Must be non-null. Each key and value must be non-null.
sortedDomain - Indicates that the resulting domain should be sorted. If true, then fr's domain is Comparable.
sortedCoDomain - Indicates that the resulting co-domain should be a sorted set. If true, then fr's co-domain is Comparable.
Returns:
The transitive closure of the function. Non-null.
  • If sortedDomain and sortedCoDomain then TreeMap<Comparable, OrderedSet<Comparable>.
  • If sortedDomain then TreeMap<Comparable, Set<Object>.
  • If sortedCoDomain then Hashtable<Object, OrderedSet<Object>.
  • Else, Hashtable<Object, Set<Object>.

functionInverse

public static <K> Map<K,Set<K>> functionInverse(Map<K,K> fr,
                                                boolean sortedDomain,
                                                boolean sortedCoDomain)
Builds an inverse function or relation of a function.

Parameters:
fr - The function. Must be non-null. Each key and value must be non-null.
sortedDomain - Indicates that the resulting domain should be sorted. If true, then fr's domain is Comparable.
sortedCoDomain - Indicates that the resulting co-domain should be a sorted set. If true, then fr's co-domain is Comparable.
Returns:
The inverse function or relation of the function. Non-null.
  • If sortedDomain and sortedCoDomain then TreeMap<Comparable, OrderedSet<Comparable>.
  • Else if sortedDomain then TreeMap<Comparable, Set<Object>.
  • Else if sortedCoDomain then Hashtable<Object, OrderedSet<Object>.
  • Else, Hashtable<Object, Set<Object>.

relationInverse

public static <K> Map<K,Set<K>> relationInverse(Map<K,Set<K>> fr,
                                                boolean sortedDomain,
                                                boolean sortedCoDomain)
Builds an inverse function or relation of a relation.

Parameters:
fr - The relation. Must be non-null. Each key and value must be non-null.
sortedDomain - Indicates that the resulting domain should be sorted. If true, then fr's domain is Comparable.
sortedCoDomain - Indicates that the resulting co-domain should be a sorted set. If true, then fr's co-domain is Set<Comparable>.
Returns:
The inverse function or relation of the relation. Non-null.
  • If sortedDomain and sortedCoDomain then TreeMap<Comparable, OrderedSet<Comparable>.
  • Else if sortedDomain then TreeMap<Comparable, Set<Object>.
  • Else if sortedCoDomain then Hashtable<Object, OrderedSet<Object>.
  • Else, Hashtable<Object, Set<Object>.