@Test public void testGetIndegree() { System.out.println("getIndegree"); assertEquals(0, g1.getIndegree(1)); assertEquals(1, g2.getIndegree(1)); g2.addEdge(1, 1); assertEquals(2, g2.getIndegree(1)); assertEquals(2, g3.getIndegree(1)); assertEquals(2, g3.getIndegree(2)); assertEquals(2, g3.getIndegree(3)); assertEquals(1, g4.getIndegree(4)); assertEquals(0, g5.getIndegree(1)); assertEquals(1, g6.getIndegree(1)); g6.addEdge(1, 1); assertEquals(2, g6.getIndegree(1)); assertEquals(2, g7.getIndegree(1)); assertEquals(2, g7.getIndegree(2)); assertEquals(2, g7.getIndegree(3)); assertEquals(2, g8.getIndegree(4)); }
@Override public int getIndegree(int vertex) { int degree = 0; for (int i = 0; i < n; i++) { if (graph[i][vertex] != 0.0) { degree++; } } return degree; }
AdjacencyMatrix implements Graph { @Override public int getIndegree(int vertex) { int degree = 0; for (int i = 0; i < n; i++) { if (graph[i][vertex] != 0.0) { degree++; } } return degree; } }
AdjacencyMatrix implements Graph { @Override public int getIndegree(int vertex) { int degree = 0; for (int i = 0; i < n; i++) { if (graph[i][vertex] != 0.0) { degree++; } } return degree; } AdjacencyMatrix(int n);  AdjacencyMatrix(int n, boolean digraph); }
AdjacencyMatrix implements Graph { @Override public int getIndegree(int vertex) { int degree = 0; for (int i = 0; i < n; i++) { if (graph[i][vertex] != 0.0) { degree++; } } return degree; } AdjacencyMatrix(int n);  AdjacencyMatrix(int n, boolean digraph); @Override int getNumVertices(); @Override boolean hasEdge(int source, int target); @Override double getWeight(int source, int target); @Override AdjacencyMatrix 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); double[] dijkstra(int s, boolean weighted); @Override AdjacencyMatrix subgraph(int[] vertices); double[][] toArray(); double pushRelabel(double[][] flow, int source, int sink); @Override Matrix toMatrix(); }
AdjacencyMatrix implements Graph { @Override public int getIndegree(int vertex) { int degree = 0; for (int i = 0; i < n; i++) { if (graph[i][vertex] != 0.0) { degree++; } } return degree; } AdjacencyMatrix(int n);  AdjacencyMatrix(int n, boolean digraph); @Override int getNumVertices(); @Override boolean hasEdge(int source, int target); @Override double getWeight(int source, int target); @Override AdjacencyMatrix 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); double[] dijkstra(int s, boolean weighted); @Override AdjacencyMatrix subgraph(int[] vertices); double[][] toArray(); double pushRelabel(double[][] flow, int source, int sink); @Override Matrix toMatrix();  }