private int getIndex(E e, EdgeIndexFunction<V, E> edgeIndexFunction) { return edgeIndexFunction == null ? 1 : edgeIndexFunction.getIndex(graph, e); }
/** * Returns a synchronized Forest backed by the passed Forest. * @param <V> the vertex type * @param <E> the edge type * @param forest the forest for which a synchronized wrapper is to be created * @return a synchronized Forest backed by the passed Forest */ public static <V,E> SynchronizedForest<V,E> synchronizedForest(Forest<V,E> forest) { return new SynchronizedForest<V,E>(forest); }
/** * Returns an unmodifiable <code>Forest</code> backed by the passed forest. * @param <V> the vertex type * @param <E> the edge type * @param forest the forest for which the unmodifiable wrapper is to be returned * @return an unmodifiable <code>Forest</code> backed by the passed forest */ public static <V,E> UnmodifiableForest<V,E> unmodifiableForest(Forest<V,E> forest) { return new UnmodifiableForest<V,E>(forest); }
/** {@inheritDoc} */ public UndirectedGraph<LabelVertex, WeightedEdge> getAffinityGraph() { return Graphs.unmodifiableUndirectedGraph( Graphs.synchronizedUndirectedGraph(affinityGraph)); }
/** * Adds {@code tree} to this graph as an element of this forest. * * @param tree * the tree to add to this forest as a component */ public void addTree(Tree<V, E> tree) { TreeUtils.addSubTree(this, tree, null, null); }
/** * Returns {@code true} if {@code edge_type} matches the default edge type * for this graph, and {@code false} otherwise. * * @param edge_type * the edge type to compare to this instance's default edge type */ protected boolean hasEqualEdgeType(EdgeType edge_type) { return this.edge_type.equals(edge_type); }
/** * @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>(); }
/** * 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>(); }
/** * Returns a synchronized DirectedGraph backed by the passed DirectedGraph. * @param <V> the vertex type * @param <E> the edge type * @param graph the graph for which a synchronized wrapper is to be created * @return a synchronized DirectedGraph backed by the passed DirectedGraph */ public static <V,E> DirectedGraph<V,E> synchronizedDirectedGraph(DirectedGraph<V,E> graph) { return new SynchronizedDirectedGraph<V,E>(graph); }
/** * Returns a synchronized Tree backed by the passed Tree. * @param <V> the vertex type * @param <E> the edge type * @param tree the tree for which a synchronized wrapper is to be created * @return a synchronized Tree backed by the passed Tree */ public static <V,E> SynchronizedTree<V,E> synchronizedTree(Tree<V,E> tree) { return new SynchronizedTree<V,E>(tree); }
/** * Returns an unmodifiable Graph backed by the passed Graph. * @param <V> the vertex type * @param <E> the edge type * @param graph the graph for which the unmodifiable wrapper is to be returned * @return an unmodifiable Graph backed by the passed Graph */ public static <V,E> Graph<V,E> unmodifiableGraph(Graph<V,E> graph) { return new UnmodifiableGraph<V,E>(graph); }
/** * Returns an unmodifiable <code>DirectedGraph</code> backed by the passed graph. * @param <V> the vertex type * @param <E> the edge type * @param graph the graph for which the unmodifiable wrapper is to be returned * @return an unmodifiable <code>DirectedGraph</code> backed by the passed graph */ public static <V,E> DirectedGraph<V,E> unmodifiableDirectedGraph(DirectedGraph<V,E> graph) { return new UnmodifiableDirectedGraph<V,E>(graph); }
/** * Returns an unmodifiable <code>UndirectedGraph</code> backed by the passed graph. * @param <V> the vertex type * @param <E> the edge type * @param graph the graph for which the unmodifiable wrapper is to be returned * @return an unmodifiable <code>UndirectedGraph</code> backed by the passed graph */ public static <V,E> UndirectedGraph<V,E> unmodifiableUndirectedGraph(UndirectedGraph<V,E> graph) { return new UnmodifiableUndirectedGraph<V,E>(graph); }
/** * Returns an unmodifiable <code>Tree</code> backed by the passed tree. * @param <V> the vertex type * @param <E> the edge type * @param tree the tree for which the unmodifiable wrapper is to be returned * @return an unmodifiable <code>Tree</code> backed by the passed tree */ public static <V,E> UnmodifiableTree<V,E> unmodifiableTree(Tree<V,E> tree) { return new UnmodifiableTree<V,E>(tree); }
@Override public Iterator<T> iterator() { return new PairIterator(); }
/** {@inheritDoc} */ public UndirectedGraph<LabelVertex, WeightedEdge> getAffinityGraph() { return Graphs.unmodifiableUndirectedGraph( Graphs.synchronizedUndirectedGraph(affinityGraph)); }
/** * Adds {@code tree} to this graph as an element of this forest. * * @param tree the tree to add to this forest as a component */ public void addTree(Tree<V,E> tree) { TreeUtils.addSubTree(this, tree, null, null); }
/** * @param edge_type the edge type to compare to this instance's default edge type * @return {@code true} if {@code edge_type} matches the default edge type for * this graph, and {@code false} otherwise */ protected boolean hasEqualEdgeType(EdgeType edge_type) { return this.edge_type.equals(edge_type); }
/** * 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>(); }
/** * @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>(); }