/** * Returns an instance of this type. * * @param <V> * the vertex type * @param <E> * the edge type */ public static <V, E> IncidentEdgeIndexFunction<V, E> getInstance() { return new IncidentEdgeIndexFunction<V, E>(); }
/** * Returns the index for the specified edge. * Calculates the indices for <code>e</code> and for all edges parallel * to <code>e</code>. */ public int getIndex(Graph<V, E> graph, E e) { Integer index = edge_index.get(e); if(index == null) { Pair<V> endpoints = graph.getEndpoints(e); V u = endpoints.getFirst(); V v = endpoints.getSecond(); if(u.equals(v)) { index = getIndex(graph, e, v); } else { index = getIndex(graph, e, u, v); } } return index.intValue(); }
/** * Returns the index for the specified edge. Calculates the indices for * <code>e</code> and for all edges parallel to <code>e</code>. */ @Override public int getIndex(Graph<V, E> graph, E e) { Integer index = edge_index.get(e); if (index == null) { Pair<V> endpoints = graph.getEndpoints(e); V u = endpoints.getFirst(); V v = endpoints.getSecond(); if (u.equals(v)) { index = getIndex(graph, e, v); } else { index = getIndex(graph, e, u, v); } } return index.intValue(); }
/** * Resets the indices for this edge and its parallel edges. Should be * invoked when an edge parallel to <code>e</code> has been added or * removed. * * @param e */ @Override public void reset(Graph<V, E> graph, E e) { Pair<V> endpoints = graph.getEndpoints(e); getIndex(graph, e, endpoints.getFirst()); getIndex(graph, e, endpoints.getFirst(), endpoints.getSecond()); }
/** * @param <V> the vertex type * @param <E> the edge type * @return an instance of this type. */ public static <V,E> IncidentEdgeIndexFunction<V,E> getInstance() { return new IncidentEdgeIndexFunction<V,E>(); }
/** * Resets the indices for this edge and its parallel edges. * Should be invoked when an edge parallel to <code>e</code> * has been added or removed. * @param graph the graph whose indices are to be reset * @param e the edge whose associated indices are to be reset */ public void reset(Graph<V,E> graph, E e) { Pair<V> endpoints = graph.getEndpoints(e); getIndex(graph, e, endpoints.getFirst()); getIndex(graph, e, endpoints.getFirst(), endpoints.getSecond()); }