/** * Returns an instance of this class. * * @param <V> * the vertex type * @param <E> * the edge type */ public static <V, E> DefaultParallelEdgeIndexFunction<V, E> getInstance() { return new DefaultParallelEdgeIndexFunction<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 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()); }
/** * 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 for which the indices are to be reset * @param e the edge whose 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()); }
/** * Returns the index for <code>e</code> in <code>graph</code>. * Calculates the indices for <code>e</code> and for all edges parallel * to <code>e</code>, if they are not already assigned. */ public int getIndex(Graph<V, E> graph, E e) { checkNotNull(graph, "graph must not be null"); checkNotNull(e, "'e' must not be null"); Integer index = edge_index.get(Context.<Graph<V,E>,E>getInstance(graph,e)); //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(); }
/** * @param <V> the vertex type * @param <E> the edge type * @return an instance of this class */ public static <V,E> DefaultParallelEdgeIndexFunction<V,E> getInstance() { return new DefaultParallelEdgeIndexFunction<V,E>(); }
/** * Returns the index for <code>e</code> in <code>graph</code>. Calculates * the indices for <code>e</code> and for all edges parallel to * <code>e</code>, if they are not already assigned. */ @Override public int getIndex(Graph<V, E> graph, E e) { Integer index = edge_index .get(Context.<Graph<V, E>, E> getInstance(graph, e)); // 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(); }