|
14 | 14 | * You should have received a copy of the GNU Lesser General Public License |
15 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | * |
17 | | - * Copyright 2023 The TweetyProject Team <http://tweetyproject.org/contact/> |
| 17 | + * Copyright 2025 The TweetyProject Team <http://tweetyproject.org/contact/> |
18 | 18 | */ |
19 | 19 | package org.tweetyproject.arg.dung.equivalence; |
20 | 20 |
|
21 | | -import java.util.Collection; |
22 | | - |
23 | 21 | import org.tweetyproject.arg.dung.syntax.DungTheory; |
24 | 22 |
|
| 23 | +import java.util.Collection; |
| 24 | + |
25 | 25 | /** |
26 | 26 | * This class defines 'syntactic' equivalence of {@link DungTheory Argumentation Frameworks}, |
27 | 27 | * i.e., it checks whether two AFs have exactly the same arguments and attacks. |
28 | 28 | * |
29 | | - * @author Julian Sander |
| 29 | + * @author Julian Sander, Lars Bengel |
30 | 30 | */ |
31 | | -public class IdentityEquivalence implements Equivalence<DungTheory> { |
32 | | - |
33 | | - @Override |
34 | | - public boolean isEquivalent(DungTheory obj1, DungTheory obj2) { |
35 | | - return obj1.equals(obj2); |
36 | | - } |
| 31 | +public class SyntacticEquivalence implements Equivalence<DungTheory> { |
| 32 | + @Override |
| 33 | + public boolean isEquivalent(DungTheory theory1, DungTheory theory2) { |
| 34 | + if (!theory1.getNodes().equals(theory2.getNodes())) return false; |
| 35 | + return theory1.getAttacks().equals(theory2.getAttacks()); |
| 36 | + } |
37 | 37 |
|
38 | | - @Override |
39 | | - public boolean isEquivalent(Collection<DungTheory> objects) { |
40 | | - DungTheory first = objects.iterator().next(); |
41 | | - for (DungTheory framework : objects) { |
42 | | - if(framework == first) { |
43 | | - continue; |
44 | | - } |
45 | | - if(!this.isEquivalent(framework, first)) { |
46 | | - return false; |
47 | | - } |
48 | | - } |
49 | | - return true; |
50 | | - } |
| 38 | + @Override |
| 39 | + public boolean isEquivalent(Collection<DungTheory> theories) { |
| 40 | + DungTheory first = theories.iterator().next(); |
51 | 41 |
|
52 | | - @Override |
53 | | - public String getName() { |
54 | | - return "Syntactic Equivalence"; |
55 | | - } |
| 42 | + for(DungTheory theory : theories) { |
| 43 | + if (!isEquivalent(theory, first)) { |
| 44 | + return false; |
| 45 | + } |
| 46 | + } |
| 47 | + return true; |
| 48 | + } |
56 | 49 |
|
| 50 | + @Override |
| 51 | + public String getName() { |
| 52 | + return "Syntactic Equivalence"; |
| 53 | + } |
57 | 54 | } |
0 commit comments