@Test public void testGetEdgeObjects() { graph.addVertex(); graph.addVertex(); int a = graph.addEdge(0, 1, "Arrow"); assertEquals(1, graph.getEdgeObjects(0, 1).size()); assertEquals(1, graph.getEdgeObjects(1, 0).size()); }
@Override public List<E> getEdgeObjects(int v1, int v2) { checkVertex(v1); checkVertex(v2); List<E> edgeObjects = new ArrayList<>(1); TIntArrayList[] adjacencyList = getAdjacencyList(); TIntArrayList adjacentEdges = adjacencyList[v1]; for (int i = 0; i < adjacentEdges.size(); i++) { int e = adjacentEdges.getQuick(i); Edge<E> edge = edges.get(e); if ((edge.getV1() == v1 && edge.getV2() == v2) || (edge.getV1() == v2 && edge.getV2() == v1)) { edgeObjects.add(edge.getObject()); } } return edgeObjects; }
UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public List<E> getEdgeObjects(int v1, int v2) { checkVertex(v1); checkVertex(v2); List<E> edgeObjects = new ArrayList<>(1); TIntArrayList[] adjacencyList = getAdjacencyList(); TIntArrayList adjacentEdges = adjacencyList[v1]; for (int i = 0; i < adjacentEdges.size(); i++) { int e = adjacentEdges.getQuick(i); Edge<E> edge = edges.get(e); if ((edge.getV1() == v1 && edge.getV2() == v2) || (edge.getV1() == v2 && edge.getV2() == v1)) { edgeObjects.add(edge.getObject()); } } return edgeObjects; } }
UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public List<E> getEdgeObjects(int v1, int v2) { checkVertex(v1); checkVertex(v2); List<E> edgeObjects = new ArrayList<>(1); TIntArrayList[] adjacencyList = getAdjacencyList(); TIntArrayList adjacentEdges = adjacencyList[v1]; for (int i = 0; i < adjacentEdges.size(); i++) { int e = adjacentEdges.getQuick(i); Edge<E> edge = edges.get(e); if ((edge.getV1() == v1 && edge.getV2() == v2) || (edge.getV1() == v2 && edge.getV2() == v1)) { edgeObjects.add(edge.getObject()); } } return edgeObjects; }  }
UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public List<E> getEdgeObjects(int v1, int v2) { checkVertex(v1); checkVertex(v2); List<E> edgeObjects = new ArrayList<>(1); TIntArrayList[] adjacencyList = getAdjacencyList(); TIntArrayList adjacentEdges = adjacencyList[v1]; for (int i = 0; i < adjacentEdges.size(); i++) { int e = adjacentEdges.getQuick(i); Edge<E> edge = edges.get(e); if ((edge.getV1() == v1 && edge.getV2() == v2) || (edge.getV1() == v2 && edge.getV2() == v1)) { edgeObjects.add(edge.getObject()); } } return edgeObjects; }  @Override int addVertex(); @Override void addVertexIfNotPresent(int v); @Override boolean vertexExists(int v); @Override V removeVertex(int v); @Override int getVertexCount(); @Override void removeAllVertices(); @Override int addEdge(int v1, int v2, E obj); @Override E removeEdge(int e); @Override void removeAllEdges(); @Override int getEdgeCount(); @Override int[] getVertices(); @Override int[] getEdges(); @Override int getVertexCapacity(); @Override Iterable<V> getVerticesObj(); @Override Stream<V> getVertexObjectStream(); @Override V getVertexObject(int v); @Override void setVertexObject(int v, V obj); @Override int getEdgeVertex1(int e); @Override int getEdgeVertex2(int e); @Override Iterable<E> getEdgesObject(); @Override Stream<E> getEdgeObjectStream(); @Override E getEdgeObject(int e); @Override List<E> getEdgeObjects(int v1, int v2); @Override void traverse(int v, Traverser traverser, boolean[] encountered); @Override void traverse(int v, Traverser traverser); @Override List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled); @Override void addListener(UndirectedGraphListener l); @Override void removeListener(UndirectedGraphListener l); @Override void print(PrintStream out, Function<V, String> vertexToString, Function<E, String> edgeToString); }
UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public List<E> getEdgeObjects(int v1, int v2) { checkVertex(v1); checkVertex(v2); List<E> edgeObjects = new ArrayList<>(1); TIntArrayList[] adjacencyList = getAdjacencyList(); TIntArrayList adjacentEdges = adjacencyList[v1]; for (int i = 0; i < adjacentEdges.size(); i++) { int e = adjacentEdges.getQuick(i); Edge<E> edge = edges.get(e); if ((edge.getV1() == v1 && edge.getV2() == v2) || (edge.getV1() == v2 && edge.getV2() == v1)) { edgeObjects.add(edge.getObject()); } } return edgeObjects; }  @Override int addVertex(); @Override void addVertexIfNotPresent(int v); @Override boolean vertexExists(int v); @Override V removeVertex(int v); @Override int getVertexCount(); @Override void removeAllVertices(); @Override int addEdge(int v1, int v2, E obj); @Override E removeEdge(int e); @Override void removeAllEdges(); @Override int getEdgeCount(); @Override int[] getVertices(); @Override int[] getEdges(); @Override int getVertexCapacity(); @Override Iterable<V> getVerticesObj(); @Override Stream<V> getVertexObjectStream(); @Override V getVertexObject(int v); @Override void setVertexObject(int v, V obj); @Override int getEdgeVertex1(int e); @Override int getEdgeVertex2(int e); @Override Iterable<E> getEdgesObject(); @Override Stream<E> getEdgeObjectStream(); @Override E getEdgeObject(int e); @Override List<E> getEdgeObjects(int v1, int v2); @Override void traverse(int v, Traverser traverser, boolean[] encountered); @Override void traverse(int v, Traverser traverser); @Override List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled); @Override void addListener(UndirectedGraphListener l); @Override void removeListener(UndirectedGraphListener l); @Override void print(PrintStream out, Function<V, String> vertexToString, Function<E, String> edgeToString);  }