@Test public void testToMatrix() { System.out.println("toMatrix digraph = false"); AdjacencyMatrix graph = new AdjacencyMatrix(8, false); graph.addEdge(0, 2); graph.addEdge(1, 7); graph.addEdge(2, 6); graph.addEdge(7, 4); graph.addEdge(3, 4); graph.addEdge(3, 5); graph.addEdge(5, 4); Matrix matrix = graph.toMatrix(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { System.out.print(matrix.get(i, j) + " "); } System.out.println(); } assertEquals(1.0, matrix.get(0, 2), 1E-10); assertEquals(1.0, matrix.get(1, 7), 1E-10); assertEquals(1.0, matrix.get(2, 6), 1E-10); assertEquals(1.0, matrix.get(7, 4), 1E-10); assertEquals(1.0, matrix.get(3, 4), 1E-10); assertEquals(1.0, matrix.get(3, 5), 1E-10); assertEquals(1.0, matrix.get(5, 4), 1E-10); assertEquals(1.0, matrix.get(2, 0), 1E-10); assertEquals(1.0, matrix.get(7, 1), 1E-10); assertEquals(1.0, matrix.get(6, 2), 1E-10); assertEquals(1.0, matrix.get(4, 7), 1E-10); assertEquals(1.0, matrix.get(4, 3), 1E-10); assertEquals(1.0, matrix.get(5, 3), 1E-10); assertEquals(1.0, matrix.get(4, 5), 1E-10); }
@Override public Matrix toMatrix() { return new Matrix(graph); }
AdjacencyMatrix implements Graph { @Override public Matrix toMatrix() { return new Matrix(graph); } }
AdjacencyMatrix implements Graph { @Override public Matrix toMatrix() { return new Matrix(graph); } AdjacencyMatrix(int n);  AdjacencyMatrix(int n, boolean digraph); }
AdjacencyMatrix implements Graph { @Override public Matrix toMatrix() { return new Matrix(graph); } 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 Matrix toMatrix() { return new Matrix(graph); } 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();  }