@Override public boolean areAdjacent(Argument a, Argument b) { return this.isAttackedBy(b, a); }
@Override public boolean hasSelfLoops() { for(Argument a: this) if(this.isAttackedBy(a, a)) return true; return false; }
/** * Determines the number of attackers from x to y. * @param theory a Dung theory. * @param y some argument * @param x some set of arguments * @return the number of attackers from x to y. */ private int numOfAttackers(DungTheory theory, Argument y, Collection<Argument> x){ int num = 0; for(Argument a: x) if(theory.isAttackedBy(y, a)) num++; return num; }
@Override public Edge<Argument> getEdge(Argument a, Argument b) { if(this.isAttackedBy(b, a)) return new Attack(a, b); return null; }
@Override public boolean isAttackedBy(Argument arg1, Argument arg2){ if(arg1 instanceof ArgumentStructure && arg2 instanceof ArgumentStructure) return ((ArgumentStructure)arg2).attacks((ArgumentStructure) arg1, this); return super.isAttackedBy(arg1, arg2); }
/** * Returns the set { a in A | a nicht in S und a -> S } * @param af some Dung theory * @param s a set of arguments * @return a set of arguments */ private Collection<Argument> getOutparents(DungTheory af, Collection<Argument> s){ Collection<Argument> result = new HashSet<Argument>(); for(Argument a: af) if(!s.contains(a)){ if(af.isAttackedBy(a, new Extension(s))) result.add(a); } return result; }
/** * Checks whether "arg1" indirectly attacks "arg2", i.e. whether there * is an odd-length path from "arg1" to "arg2". * @param arg1 an AbstractArgument. * @param arg2 an AbstractArgument. * @param visited already visited arguments. * @return "true" iff "arg1" indirectly attacks "arg2". */ private boolean isIndirectAttack(Argument arg1, Argument arg2, Set<Argument> visited){ if(this.isAttackedBy(arg2,arg1)) return true; visited.add(arg1); Set<Argument> attackedArguments = this.getAttacked(arg1); attackedArguments.removeAll(visited); for(Argument attacked : attackedArguments){ if(this.isSupport(attacked, arg2)) return true; } return false; }
/** * returns true if no accepted argument attacks another accepted one in * this interpretation wrt. the given theory. * @param dungTheory a Dung theory. * @return true if no accepted argument attacks another accepted one in * this interpretation wrt. the given theory. */ public boolean isConflictFree(DungTheory dungTheory){ for(Argument a: this.getArgumentsOfStatus(ArgumentStatus.IN)) for(Argument b: this.getArgumentsOfStatus(ArgumentStatus.IN)) if(dungTheory.isAttackedBy(a, b)) return false; return true; }
@Override public DungTheory getComplementGraph(int selfloops) { DungTheory comp = new DungTheory(); for(Argument node: this) comp.add(node); for(Argument node1: this) for(Argument node2: this) if(node1 == node2){ if(selfloops == Graph.INVERT_SELFLOOPS){ if(!this.isAttackedBy(node2, node1)) comp.add(new Attack(node1, node2)); }else if(selfloops == Graph.IGNORE_SELFLOOPS){ if(this.isAttackedBy(node2, node1)) comp.add(new Attack(node1, node2)); } }else if(!this.isAttackedBy(node2, node1)) comp.add(new Attack(node1, node2)); return comp; }
for(Argument a: theory){ for(Argument b: theory){ if(!theory.isAttackedBy(b, a)){ DungTheory newTheory = new DungTheory(); newTheory.addAll(theory);