package graph;

import java.io.InputStream;
import java.util.LinkedList;
import java.util.NoSuchElementException;

/**
 * Created by Paweł Kopeć on 23.12.16.
 *
 * Implementation of graph data structure
 * based on adjacency matrix.
 */
public class MatrixGraph extends Graph {

    int[][] adjacencyMatrix;

    MatrixGraph() {
        super();
    }

    MatrixGraph(int verticesNumber, int edgesNumber) {
        super(verticesNumber, edgesNumber);
    }

    public MatrixGraph(InputStream in) {
        super(in);
    }

    @Override
    protected void initContainers(int verticesNumber, int edgesNumber) {

    }

    @Override
    public void addVertex() {

    }

    @Override
    public void removeVertex(int index) throws NoSuchElementException {

    }

    @Override
    public void addEdge(int from, int to) throws IllegalArgumentException {

    }

    @Override
    public void removeEdge(int from, int to) throws IllegalArgumentException {

    }

    @Override
    public LinkedList<Integer> getNeighbours(int index) throws NoSuchElementException {
        return new LinkedList<>();
    }

    @Override
    public boolean hasEdge(int from, int to) throws IllegalArgumentException {
        return false;
    }

    @Override
    public void makeEmpty() {

    }

    @Override
    public String toString() {
        return super.toString();
    }
}
@@ -232,50 +232,243 @@
 .%0A *
-/%0Apublic class MatrixGraph extends Graph %7B
+%0A * TODO%0A * Think of data structure for adjacency matrix%0A * based on bit operations, not integers.%0A */%0Apublic class MatrixGraph extends Graph %7B%0A%0A    private static final int CONNECTED = 1;%0A    private static final int DISCONNECTED = 0;
 %0A%0A  
@@ -795,24 +795,90 @@
 esNumber) %7B%0A
+        adjacencyMatrix = new int%5BverticesNumber%5D%5BverticesNumber%5D;
 %0A    %7D%0A%0A    
@@ -1113,252 +1113,1048 @@
 n %7B%0A
-%0A    %7D%0A%0A    @Override%0A    public void removeEdge(int from, int to) throws IllegalArgumentException %7B%0A%0A    %7D%0A%0A    @Override%0A    public LinkedList%3CInteger%3E getNeighbours(int index) throws NoSuchElementException %7B%0A        return new LinkedList%3C%3E()
+        if(!isValidEdge(from, to)) %7B%0A            throw new IllegalArgumentException(INVALID_EDGE);%0A        %7D%0A        adjacencyMatrix%5Bfrom%5D%5Bto%5D = CONNECTED;%0A        adjacencyMatrix%5Bto%5D%5Bfrom%5D = CONNECTED;%0A        edgesNumber++;%0A    %7D%0A%0A    @Override%0A    public void removeEdge(int from, int to) throws IllegalArgumentException %7B%0A        if(!hasEdge(from, to)) %7B%0A            throw new IllegalArgumentException(NO_SUCH_EDGE);%0A        %7D%0A        adjacencyMatrix%5Bfrom%5D%5Bto%5D = DISCONNECTED;%0A        adjacencyMatrix%5Bto%5D%5Bfrom%5D = DISCONNECTED;%0A        edgesNumber--;%0A    %7D%0A%0A    @Override%0A    public LinkedList%3CInteger%3E getNeighbours(int index) throws NoSuchElementException %7B%0A        if(!isValidVertex(index)) %7B%0A            throw new IllegalArgumentException(INVALID_VERTEX);%0A        %7D%0A        LinkedList%3CInteger%3E neighbours = new LinkedList%3C%3E();%0A        for(int i = 0; i %3C adjacencyMatrix%5Bindex%5D.length; i++) %7B%0A            if(adjacencyMatrix%5Bindex%5D%5Bi%5D == CONNECTED) %7B%0A                neighbours.add(i);%0A            %7D%0A        %7D%0A        return neighbours
 ;%0A  
@@ -2270,13 +2270,46 @@
 urn 
-false
+adjacencyMatrix%5Bfrom%5D%5Bto%5D == CONNECTED
 ;%0A  
@@ -2353,24 +2353,205 @@
 keEmpty() %7B%0A
+        for(int i = 0; i %3C verticesNumber; i++) %7B%0A            for(int j = 0; j %3C verticesNumber; j++) %7B%0A                adjacencyMatrix%5Bi%5D%5Bj%5D = DISCONNECTED;%0A            %7D%0A        %7D
 %0A    %7D%0A%0A    

implement basic methods