public void addIncomingEdge(Edge<MultiNode> e) { incomingEdges.put(e.getType(), e); }
/** * Remove a given edge */ public void removeEdge(E e) { List<E> l = adjList.get(e.getType()); if (l == null) return; l.remove(e); }
/** * Check the edges source/target for this node and returns true if this * node contains the given edge as incoming or outgoing edge. */ public boolean containsEdge(Edge<MultiNode> e) { if (e.getSource() == this) { Edge e1 = incomingEdges.get(e.getType()); return (e1 != null && e1 == e); } else { ArrayList<Edge<MultiNode>> l = outgoingEdges.get(e.getType()); if (l != null) { return l.contains(e); } } return false; }
public boolean equals(Object o) { if (o == null) return false; if (o instanceof Edge) { //if both edges are of type 'undirected', it doesn't matter what is source and what target if (this.getType().equals(EdgeType.UNDIRECTED) && ((Edge) o).getType().equals(EdgeType.UNDIRECTED)) { return ((Edge) o).getSource().equals(source) && ((Edge) o).getTarget().equals(target) || ((Edge) o).getSource().equals(target) && ((Edge) o).getTarget().equals(source); } else { return ((Edge) o).getSource().equals(source) && ((Edge) o).getTarget().equals(target); } } return false; }
public void removeEdge(E e) { removeEdge(e.getSource(), e.getTarget(), e.getType()); }