/** * Return true if the given argument is in this attack relation. * @param argument some argument * @return true if the given argument is in this attack relation. */ public boolean contains(Argument argument){ return this.getAttacked().equals(argument) || this.getAttacker().equals(argument); }
@Override public Edge<Argument> getEdge(Argument a, Argument b) { if(this.isAttackedBy(b, a)) return new Attack(a, b); return null; }
public Signature getSignature(){ DungSignature sig = new DungSignature(); sig.add(this.getAttacked()); sig.add(this.getAttacker()); return sig; }
@Override public Graph<Argument> getRestriction(Collection<Argument> arguments) { DungTheory theory = new DungTheory(); theory.addAll(arguments); for (Attack attack: this.getAttacks()) if(arguments.contains(attack.getAttacked()) && arguments.contains(attack.getAttacker())) theory.add(attack); return theory; }
/** * Returns the view of the universal Dung theory restricted to * the given set of arguments. * @param arguments a set of arguments. * @return the projection of the universal theory. */ public DungTheory getPerceivedDungTheory(Extension arguments){ return new DungTheory(this.universalTheory.getRestriction(arguments)); } }
@Override public void write(DungTheory aaf, File f) throws IOException { PrintWriter writer = new PrintWriter(f, "UTF-8"); for(Argument a: aaf) writer.println("arg(" + a.getName() + ")."); for(Attack att: aaf.getAttacks()) writer.println("att(" + att.getAttacker().getName() + "," + att.getAttacked().getName() + ")."); writer.close(); }
public int hashCode(){ return this.getAttacked().hashCode() + 7 * this.getAttacker().hashCode(); }
/** * Adds all arguments and attacks of the given theory to * this theory * @param theory some Dung theory * @return "true" if this Dung Theory has been modified */ public boolean add(DungTheory theory){ boolean b1 = this.addAll(theory); boolean b2 = this.addAllAttacks(theory.getAttacks()); return b1 || b2 ; }
@Override public DungSignature getSignature() { DungSignature reval = new DungSignature(); reval.add(new Argument(this.predicate.getName())); return reval; }
public String toString(){ return "("+this.getAttacker().toString()+","+this.getAttacked().toString()+")"; }
/** * Adds the set of attacks to this Dung theory. * @param c a collection of attacks * @return "true" if this Dung theory has been modified. */ public boolean addAllAttacks(Collection<? extends Attack> c){ boolean result = false; for(Attack att: c) result |= this.add(att); return result; }
/** * Adds the given attack to this dung theory. * @param attack an attack * @return "true" if the set of attacks has been modified. */ public boolean add(Attack attack){ return this.addAttack(attack.getAttacker(), attack.getAttacked()); }
@Override public boolean hasSelfLoops() { for(Argument a: this) if(this.isAttackedBy(a, a)) return true; return false; }
@Override public boolean containsAll(Collection<?> c){ for(Object o: c) if(!this.contains(o)) return false; return true; }
/** * returns the attacking argument of this attack relation. * @return the attacking argument of this attack relation. */ public Argument getAttacker() { return this.getNodeA(); }
/** * returns the attacked argument of this attack relation. * @return the attacked argument of this attack relation. */ public Argument getAttacked() { return this.getNodeB(); }
public boolean equals(Object o){ if(!o.getClass().equals(this.getClass())) return false; if(!this.getAttacker().equals(((Attack)o).getAttacker())) return false; if(!this.getAttacked().equals(((Attack)o).getAttacked())) return false; return true; }
@Override public void write(DungTheory aaf, File f) throws IOException { PrintWriter writer = new PrintWriter(f, "UTF-8"); for(Argument a: aaf) writer.println(a.getName()); writer.println("#"); for(Attack att: aaf.getAttacks()) writer.println(att.getAttacker().getName() + " " + att.getAttacked().getName()); writer.close(); }