piccola variazione a adjacency list
This commit is contained in:
@@ -67,8 +67,7 @@ public class AdjacencyListGraph<V,E> implements Graph<V,E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the other endvertex of an incident edge
|
// Return the other endvertex of an incident edge
|
||||||
public Vertex<V> opposite(Vertex<V> v, Edge<E> e)
|
public Vertex<V> opposite(Vertex<V> v, Edge<E> e) throws InvalidPositionException {
|
||||||
throws InvalidPositionException {
|
|
||||||
checkVertex(v);
|
checkVertex(v);
|
||||||
MyEdge<E> ee = checkEdge(e);
|
MyEdge<E> ee = checkEdge(e);
|
||||||
Vertex<V>[] endv = ee.endVertices();
|
Vertex<V>[] endv = ee.endVertices();
|
||||||
@@ -81,8 +80,7 @@ public class AdjacencyListGraph<V,E> implements Graph<V,E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test whether two vertices are adjacent
|
// Test whether two vertices are adjacent
|
||||||
public boolean areAdjacent(Vertex<V> u, Vertex<V> v)
|
public boolean areAdjacent(Vertex<V> u, Vertex<V> v) throws InvalidPositionException {
|
||||||
throws InvalidPositionException {
|
|
||||||
// search the incidence list of the vertex with smaller degree
|
// search the incidence list of the vertex with smaller degree
|
||||||
Iterable<Edge<E>> iterToSearch;
|
Iterable<Edge<E>> iterToSearch;
|
||||||
if (degree(u) < degree(v)) {
|
if (degree(u) < degree(v)) {
|
||||||
@@ -110,8 +108,7 @@ public class AdjacencyListGraph<V,E> implements Graph<V,E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insert and return a new edge with a given element between two vertices
|
// Insert and return a new edge with a given element between two vertices
|
||||||
public Edge<E> insertEdge(Vertex<V> v, Vertex<V> w, E o)
|
public Edge<E> insertEdge(Vertex<V> v, Vertex<V> w, E o) throws InvalidPositionException {
|
||||||
throws InvalidPositionException {
|
|
||||||
MyVertex<V> vv = checkVertex(v);
|
MyVertex<V> vv = checkVertex(v);
|
||||||
MyVertex<V> ww = checkVertex(w);
|
MyVertex<V> ww = checkVertex(w);
|
||||||
MyEdge<E> ee = new MyEdge<E>(v, w, o);
|
MyEdge<E> ee = new MyEdge<E>(v, w, o);
|
||||||
|
|||||||
Reference in New Issue
Block a user