public Collection<E> getOutEdges(V vertex) { if (!containsVertex(vertex)) return null; return Collections.unmodifiableCollection(vertices.get(vertex).getSecond()); }
@Override public Collection<E> getOutEdges(V vertex) { if (!containsVertex(vertex)) { return null; } return Collections .unmodifiableCollection(vertices.get(vertex).getSecond()); }
@Override public E findEdge(V v1, V v2) { if (!containsVertex(v1) || !containsVertex(v2)) { return null; } for (E edge : getOutgoing_internal(v1)) { if (this.getOpposite(v1, edge).equals(v2)) { return edge; } } return null; }
@Override public E findEdge(V v1, V v2) { if (!containsVertex(v1) || !containsVertex(v2)) return null; for (E edge : getOutgoing_internal(v1)) if (this.getOpposite(v1, edge).equals(v2)) return edge; return null; }
public Collection<E> getInEdges(V vertex) { if (!containsVertex(vertex)) return null; return Collections.unmodifiableCollection(vertices.get(vertex).getFirst()); }
@Override public Collection<E> getInEdges(V vertex) { if (!containsVertex(vertex)) { return null; } return Collections .unmodifiableCollection(vertices.get(vertex).getFirst()); }
public Collection<E> getIncidentEdges(V vertex) { if (!containsVertex(vertex)) return null; Collection<E> out = new HashSet<E>(); out.addAll(this.getInEdges(vertex)); out.addAll(this.getOutEdges(vertex)); return out; }
@Override public Collection<E> getIncidentEdges(V vertex) { if (!containsVertex(vertex)) { return null; } Collection<E> out = new HashSet<E>(); out.addAll(this.getInEdges(vertex)); out.addAll(this.getOutEdges(vertex)); return out; }
@Override public Collection<V> getNeighbors(V vertex) { if (!containsVertex(vertex)) { return null; } Collection<V> out = new HashSet<V>(); out.addAll(this.getPredecessors(vertex)); out.addAll(this.getSuccessors(vertex)); return out; }
public Collection<V> getNeighbors(V vertex) { if (!containsVertex(vertex)) return null; Collection<V> out = new HashSet<V>(); out.addAll(this.getPredecessors(vertex)); out.addAll(this.getSuccessors(vertex)); return out; }
@Override public boolean isSource(V vertex, E edge) { if (!containsEdge(edge) || !containsVertex(vertex)) { return false; } return getSource(edge).equals(vertex); }
@Override public boolean isDest(V vertex, E edge) { if (!containsEdge(edge) || !containsVertex(vertex)) { return false; } return getDest(edge).equals(vertex); }
public boolean isSource(V vertex, E edge) { if (!containsEdge(edge) || !containsVertex(vertex)) return false; return getSource(edge).equals(vertex); }
public boolean isDest(V vertex, E edge) { if (!containsEdge(edge) || !containsVertex(vertex)) return false; return getDest(edge).equals(vertex); }
public boolean removeVertex(V vertex) { if (!containsVertex(vertex)) return false; // copy to avoid concurrent modification in removeEdge Set<E> incident = new HashSet<E>(getIncoming_internal(vertex)); incident.addAll(getOutgoing_internal(vertex)); for (E edge : incident) removeEdge(edge); vertices.remove(vertex); return true; }
@Override public boolean removeVertex(V vertex) { if (!containsVertex(vertex)) { return false; } // copy to avoid concurrent modification in removeEdge Set<E> incident = new HashSet<E>(getIncoming_internal(vertex)); incident.addAll(getOutgoing_internal(vertex)); for (E edge : incident) { removeEdge(edge); } vertices.remove(vertex); return true; }
public Collection<V> getSuccessors(V vertex) { if (!containsVertex(vertex)) return null; Set<V> succs = new HashSet<V>(); for (E edge : getOutgoing_internal(vertex)) { if(getEdgeType(edge) == EdgeType.DIRECTED) { succs.add(this.getDest(edge)); } else { succs.add(getOpposite(vertex, edge)); } } return Collections.unmodifiableCollection(succs); }
public Collection<V> getPredecessors(V vertex) { if (!containsVertex(vertex)) return null; Set<V> preds = new HashSet<V>(); for (E edge : getIncoming_internal(vertex)) { if(getEdgeType(edge) == EdgeType.DIRECTED) { preds.add(this.getSource(edge)); } else { preds.add(getOpposite(vertex, edge)); } } return Collections.unmodifiableCollection(preds); }
@Override public Collection<V> getSuccessors(V vertex) { if (!containsVertex(vertex)) { return null; } Set<V> succs = new HashSet<V>(); for (E edge : getOutgoing_internal(vertex)) { if (getEdgeType(edge) == EdgeType.DIRECTED) { succs.add(this.getDest(edge)); } else { succs.add(getOpposite(vertex, edge)); } } return Collections.unmodifiableCollection(succs); }
@Override public Collection<V> getPredecessors(V vertex) { if (!containsVertex(vertex)) { return null; } Set<V> preds = new HashSet<V>(); for (E edge : getIncoming_internal(vertex)) { if (getEdgeType(edge) == EdgeType.DIRECTED) { preds.add(this.getSource(edge)); } else { preds.add(getOpposite(vertex, edge)); } } return Collections.unmodifiableCollection(preds); }