/* * (non-Javadoc) * @see de.hpi.bpt.graph.abs.IDirectedEdge#setVertices(de.hpi.bpt.hypergraph.abs.IVertex, de.hpi.bpt.hypergraph.abs.IVertex) */ @SuppressWarnings("unchecked") public void setVertices(V s, V t) { if (this.graph == null) return; if (s == null || t == null) return; if (!this.graph.isMultiGraph()) { Collection<IDirectedHyperEdge<V>> es = this.graph.getEdgesWithSourceAndTarget(s, t); if (es.size() > 0) { Iterator<IDirectedHyperEdge<V>> i = es.iterator(); while (i.hasNext()) { IDirectedHyperEdge<V> e = i.next(); if (e.getVertices().size() == 2) return; } } } Collection<V> ss = new ArrayList<V>(); Collection<V> ts = new ArrayList<V>(); if (this.source != null && this.target != null) { ss.add(this.source); ts.add(this.target); super.removeSourceAndTagetVertices(ss, ts); } ss.clear(); ss.add(s); ts.clear(); ts.add(t); super.addSourceAndTagetVertices(ss, ts); this.source = s; this.target = t; }
/* * (non-Javadoc) * @see de.hpi.bpt.graph.abs.IDirectedEdge#setTarget(de.hpi.bpt.hypergraph.abs.IVertex) */ public V setTarget(V v) { if (this.graph == null) return null; Collection<V> ts = new ArrayList<V>(); ts.add(v); if (!this.checkEdge(super.source, ts)) return null; super.removeTargetVertex(this.target); this.target = super.addTargetVertex(v); return this.target; }
/* * (non-Javadoc) * @see de.hpi.bpt.graph.abs.IDirectedEdge#setSource(de.hpi.bpt.hypergraph.abs.IVertex) */ public V setSource(V v) { if (this.graph == null) return null; Collection<V> ss = new ArrayList<V>(); ss.add(v); if (!this.checkEdge(ss, super.target)) return null; super.removeSourceVertex(this.source); this.source = super.addSourceVertex(v); return this.source; }
/* * (non-Javadoc) * @see de.hpi.bpt.hypergraph.abs.AbstractDirectedHyperEdge#destroy() */ @Override public void destroy() { super.destroy(); this.graph = null; }