import("sets")
importFrom("cluster", "silhouette")
importFrom("stats", "median")
importFrom("stats", "na.omit")
importFrom("slam",
           "simple_triplet_matrix",
           "simple_triplet_diag_matrix", "simple_triplet_zero_matrix",
           "as.simple_triplet_matrix", "is.simple_triplet_matrix")
importFrom("grDevices", "gray")
importFrom("graphics", "axis", "image.default", "par", "plot")

export("as.ranking",
       "as.relation",
       "as.relation_ensemble",
       "asy",
       "codual",
       "endorelation",
       "homorelation",
       "is.ranking",
       "is.relation",
       "is.relation_ensemble",
       "ranking",
       "reflexive_reduction",
       "reflexive_closure",
       "relation",
       "relation_arity",
       "relation_charfun",
       "relation_choice",
       "relation_class_ids",
       "relation_classes",
       "relation_component_representation",
       "relation_connected_components",
       "relation_condensation",
       "relation_consensus",
       "relation_cover",
       "relation_dissimilarity",
       "relation_domain",
       "relation_domain<-",
       "relation_domain_names",
       "relation_domain_names<-",
       "relation_elements",
       "relation_ensemble",
       "relation_graph",
       "relation_graph<-",
       "relation_has_missings",
       "relation_impute",
       "relation_incidence",
       "relation_incidence<-",
       "relation_is",
       "relation_is_Euclidean",
       "relation_is_Ferrers",
       "relation_is_antisymmetric",
       "relation_is_asymmetric",
       "relation_is_acyclic",
       "relation_is_bijective",
       "relation_is_binary",
       "relation_is_complete",
       "relation_is_cyclic",
       "relation_is_endorelation",
       "relation_is_strongly_complete",
       "relation_is_coreflexive",
       "relation_is_crisp",
       "relation_is_endorelation",
       "relation_is_equivalence",
       "relation_is_functional",
       "relation_is_homogeneous",
       "relation_is_injective",
       "relation_is_interval_order",
       "relation_is_irreflexive",
       "relation_is_left_total",
       "relation_is_linear_order",
       "relation_is_match",
       "relation_is_negatively_transitive",
       "relation_is_partial_order",
       "relation_is_preference",
       "relation_is_quaternary",
       "relation_is_quasitransitive",
       "relation_is_reflexive",
       "relation_is_right_total",
       "relation_is_semiorder",
       "relation_is_semitransitive",
       "relation_is_strict_linear_order",
       "relation_is_strict_partial_order",
       "relation_is_surjective",
       "relation_is_symmetric",
       "relation_is_ternary",
       "relation_is_tournament",
       "relation_is_transitive",
       "relation_is_trichotomous",
       "relation_is_weak_order",
       "relation_is_preorder",
       "relation_is_quasiorder",
       "relation_size",
       "relation_pclust",
       "relation_properties",
       "relation_property",
       "relation_scores",
       "relation_table",
       "relation_trace",
       "relation_violations",
       "sym",
       "transform_incidences",
       "transitive_reduction",
       "transitive_closure"
       )

S3method("[", "relation")
S3method("[", "relation_ensemble")
S3method("[<-", "relation_ensemble")
S3method("[[<-", "relation_ensemble")
S3method("$<-", "relation_ensemble")
S3method("Ops", "relation")
S3method("Ops", "relation_ensemble")
S3method("relation_scores", "relation")
S3method("relation_scores", "relation_ensemble")
S3method("Summary", "relation")
S3method("Summary", "relation_ensemble")
S3method("all.equal", "relation")
S3method("all.equal", "relation_ensemble")
S3method("aperm", "relation")
S3method("as.list", "relation_ensemble")
S3method("c", "relation_ensemble")
S3method("cut", "relation")
S3method("dim", "relation")
S3method("is.na", "relation")
S3method("mean", "relation_ensemble")
S3method("na.omit", "relation")
S3method("plot", "relation")
S3method("plot", "relation_ensemble")
S3method("plot", "relation_incidence")
S3method("plot", "ranking")
S3method("print", "relation")
S3method("print", "ranking")
S3method("print", "relation_charfun")
S3method("print", "relation_classes_of_objects")
S3method("print", "relation_domain")
S3method("print", "relation_graph")
S3method("print", "relation_ensemble")
S3method("print", "relation_incidence")
S3method("print", "relation_pclust")
S3method("print", "relation_table")
S3method("print", "summary.relation")
S3method("rep", "relation_ensemble")
S3method("summary", "relation")
S3method("rev", "relation")
S3method("t", "relation")
S3method("t", "relation_ensemble")
S3method("rev", "relation_ensemble")
S3method("rev", "ranking")
S3method("t", "ranking")
S3method("unique", "relation_ensemble")

S3method("closure", "relation")
S3method("reduction", "relation")

S3method("codual", "relation")

S3method("sym", "relation")
S3method("asy", "relation")

S3method("as.relation", "default")
S3method("as.relation", "array")
S3method("as.relation", "character")
S3method("as.relation", "cl_partition")
S3method("as.relation", "data.frame")
S3method("as.relation", "factor")
S3method("as.relation", "integer")
S3method("as.relation", "logical")
S3method("as.relation", "matrix")
S3method("as.relation", "numeric")
S3method("as.relation", "ordered")
S3method("as.relation", "relation")
S3method("as.relation", "ranking")
S3method("as.relation", "ser_permutation")

S3method("as.ranking", "default")
S3method("as.ranking", "ranking")
S3method("as.ranking", "relation")

S3method("as.data.frame", "relation")

S3method("as.relation_ensemble", "data.frame")
S3method("as.relation_ensemble", "default")
S3method("as.relation_ensemble", "relation_ensemble")

## Relational algebra.
export("%><%",
       "%=><%",
       "%><=%",
       "%=><=%",
       "%|><%",
       "%><|%",
       "%|><|%",
       "%|>%",
       "%<|%",
       "%U%",
       "relation_antijoin",
       "relation_cartesian",
       "relation_complement",
       "relation_division",
       "relation_intersection",
       "relation_join",
       "relation_projection",
       "relation_selection",
       "relation_semijoin",
       "relation_symdiff",
       "relation_union"
       )

## S3 methods for internal S3 generics.

S3method(".arity", "ranking")
S3method(".arity", "relation")
S3method(".arity", "relation_ensemble")
S3method(".arity", "relation_by_domain_and_incidence")
S3method(".arity", "relation_by_domain_and_scores")

S3method(".as.ranking.relation","relation_by_domain_and_scores")
S3method(".as.ranking.relation","relation_by_domain_and_incidence")

S3method(".domain", "ranking")
S3method(".domain", "relation")
S3method(".domain", "relation_ensemble")
S3method(".domain", "relation_by_domain_and_incidence")
S3method(".domain", "relation_by_domain_and_scores")

S3method(".incidence", "relation")
S3method(".incidence", "relation_by_domain_and_incidence")
S3method(".incidence", "relation_by_domain_and_scores")

S3method(".make_relation_graph_components", "data.frame")
S3method(".make_relation_graph_components", "default")
S3method(".make_relation_graph_components", "list")
S3method(".make_relation_graph_components", "set")
S3method(".make_relation_graph_components", "gset")
S3method(".make_relation_graph_components", "matrix")
S3method(".make_relation_graph_components", "relation")

S3method(".size", "ranking")
S3method(".size", "relation")
S3method(".size", "relation_ensemble")
S3method(".size", "relation_by_domain_and_incidence")
S3method(".size", "relation_by_domain_and_scores")

S3method("as.relation", "set")
S3method("as.set", "relation_graph")

S3method("as.gset", "relation_graph")
S3method("as.relation", "gset")
S3method("as.tuple", "relation")
S3method("as.tuple", "relation_domain")
