@Test public void testGetDegree() { System.out.println("getDegree"); assertEquals(0, g1.getDegree(1)); assertEquals(2, g2.getDegree(1)); g2.addEdge(1, 1); assertEquals(4, g2.getDegree(1)); assertEquals(4, g3.getDegree(1)); assertEquals(4, g3.getDegree(2)); assertEquals(4, g3.getDegree(3)); assertEquals(2, g4.getDegree(4)); assertEquals(0, g5.getDegree(1)); assertEquals(1, g6.getDegree(1)); g6.addEdge(1, 1); assertEquals(2, g6.getDegree(1)); assertEquals(2, g7.getDegree(1)); assertEquals(2, g7.getDegree(2)); assertEquals(2, g7.getDegree(3)); assertEquals(2, g8.getDegree(4)); }
@Override public int getDegree(int vertex) { if (digraph) { return getIndegree(vertex) + getOutdegree(vertex); } else { return getOutdegree(vertex); } }
AdjacencyList implements Graph { @Override public int getDegree(int vertex) { if (digraph) { return getIndegree(vertex) + getOutdegree(vertex); } else { return getOutdegree(vertex); } } }
AdjacencyList implements Graph { @Override public int getDegree(int vertex) { if (digraph) { return getIndegree(vertex) + getOutdegree(vertex); } else { return getOutdegree(vertex); } } AdjacencyList(int n); @SuppressWarnings("unchecked")  AdjacencyList(int n, boolean digraph); }
AdjacencyList implements Graph { @Override public int getDegree(int vertex) { if (digraph) { return getIndegree(vertex) + getOutdegree(vertex); } else { return getOutdegree(vertex); } } AdjacencyList(int n); @SuppressWarnings("unchecked")  AdjacencyList(int n, boolean digraph); @Override int getNumVertices(); @Override boolean hasEdge(int source, int target); @Override double getWeight(int source, int target); @Override AdjacencyList setWeight(int source, int target, double weight); @Override Collection<Edge> getEdges(); @Override Collection<Edge> getEdges(int vertex); @Override Collection<Edge> getEdges(int source, int target); @Override Edge getEdge(int source, int target); @Override void addEdge(int source, int target); @Override void addEdge(int source, int target, double weight); @Override void removeEdges(Collection<Edge> edges); @Override void removeEdge(int source, int target); @Override void removeEdge(Edge edge); @Override int getDegree(int vertex); @Override int getIndegree(int vertex); @Override int getOutdegree(int vertex); @Override int[] sortdfs(); @Override int[][] dfs(); @Override void dfs(Visitor visitor); @Override int[] sortbfs(); @Override int[][] bfs(); @Override void bfs(Visitor visitor); @Override double[] dijkstra(int s); @Override AdjacencyList subgraph(int[] vertices); @Override SparseMatrix toMatrix(); static AdjacencyList of(SparseMatrix matrix); }
AdjacencyList implements Graph { @Override public int getDegree(int vertex) { if (digraph) { return getIndegree(vertex) + getOutdegree(vertex); } else { return getOutdegree(vertex); } } AdjacencyList(int n); @SuppressWarnings("unchecked")  AdjacencyList(int n, boolean digraph); @Override int getNumVertices(); @Override boolean hasEdge(int source, int target); @Override double getWeight(int source, int target); @Override AdjacencyList setWeight(int source, int target, double weight); @Override Collection<Edge> getEdges(); @Override Collection<Edge> getEdges(int vertex); @Override Collection<Edge> getEdges(int source, int target); @Override Edge getEdge(int source, int target); @Override void addEdge(int source, int target); @Override void addEdge(int source, int target, double weight); @Override void removeEdges(Collection<Edge> edges); @Override void removeEdge(int source, int target); @Override void removeEdge(Edge edge); @Override int getDegree(int vertex); @Override int getIndegree(int vertex); @Override int getOutdegree(int vertex); @Override int[] sortdfs(); @Override int[][] dfs(); @Override void dfs(Visitor visitor); @Override int[] sortbfs(); @Override int[][] bfs(); @Override void bfs(Visitor visitor); @Override double[] dijkstra(int s); @Override AdjacencyList subgraph(int[] vertices); @Override SparseMatrix toMatrix(); static AdjacencyList of(SparseMatrix matrix);  }