KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgrapht > experimental > equivalence > EquivalenceComparator


1 /* ==========================================
2  * JGraphT : a free Java graph-theory library
3  * ==========================================
4  *
5  * Project Info: http://jgrapht.sourceforge.net/
6  * Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh)
7  *
8  * (C) Copyright 2003-2006, by Barak Naveh and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this library; if not, write to the Free Software Foundation,
22  * Inc.,
23  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
24  */

25 /* -----------------
26  * EquivalenceComparator.java
27  * -----------------
28  * (C) Copyright 2005-2006, by Assaf Lehr and Contributors.
29  *
30  * Original Author: Assaf Lehr
31  * Contributor(s): -
32  *
33  * $Id: EquivalenceComparator.java 504 2006-07-03 02:37:26Z perfecthash $
34  *
35  * Changes
36  * -------
37  */

38 package org.jgrapht.experimental.equivalence;
39
40 /**
41  * This interface distinguishes between Equivalence sets.
42  *
43  * <p>It is similar, in concept, to the Object.hashcode() and Object.equals()
44  * methods, but instead of checking whether two objects are equal, it is used to
45  * check whether they are part of the same Equivalence group, where the
46  * definition of an "equivalence" is defined by the implementation of this
47  * interface.
48  *
49  * <p>A specific usage of it is shown below, but it may be used outside of the
50  * graph-theory class library.
51  *
52  * <p>In Isomorphism, edges/vertexes matching may relay on none/some/all of the
53  * vertex/edge properties. For example, if a vertex representing a person
54  * contains two properties: gender(male/female) and person name(string), we can
55  * decide that to check isomorphism in vertex groups of gender only. Meaning if
56  * this is the graph:
57  *
58  * <p>(male,"Don")---->(female,"Dana")--->(male,"John")
59  *
60  * <p>if there is no equivalence set at all , this graph can be described as:
61  * (1)---->(2)---->(3)
62  *
63  * <p>if the equivalence set is determined only by the gender property :
64  * (male)---->(female)---->(male)
65  *
66  * <p>and if it is determined by both properties: (the original figure) The
67  * isomorphism inspection may return different result according to this choice.
68  * If the other graph is: (male,"Don")--->(male,"Sunny")---->(male,"Jo") In no
69  * eq.set they are Isomorphic, but for the two other cases they are not. Other
70  * examples: Nodes with the same degree, Edges with the same weight, Graphs with
71  * the same number of nodes and edges.
72  *
73  * @param <E> the type of the elements in the set
74  * @param <C> the type of the context the element is compared against, e.g. a
75  * Graph
76  *
77  * @author Assaf
78  * @since Jul 15, 2005
79  */

80 public interface EquivalenceComparator<E, C>
81 {
82
83     //~ Methods ---------------------------------------------------------------
84

85     public boolean equivalenceCompare(
86         E arg1,
87         E arg2,
88         C context1,
89         C context2);
90
91     public int equivalenceHashcode(E arg1, C context);
92 }
93
Popular Tags