Simple add function to a adjacency matrix
<p>I'm developing an adjacency matrix so i can try and use a DFS to solve the euler circuit problem.
This is the relevant code to my question:</p>

<pre><code>public class Graph {

private int numVertex;
private int numEdges;
private boolean[][] adj;

public Graph(int numVertex, int numEdges) {
    this.numVertex = numVertex;
    this.numEdges = numEdges;
    this.adj = new boolean[numVertex][numVertex];
}

public void addEdge(int start, int end){
    if(!adj[start][end])
        numEdges++;
    adj[start][end] = true;
    adj[end][start] = true;
}
</code></pre>

<p>When i try and test run this code by adding some edges i get:</p>

<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Graph.addEdge(Graph.java:18)
at Graph.main(Graph.java:66)
</code></pre>

<p>I'm using this to test the code:</p>

<pre><code>    public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

    int numVertices = input.nextInt();
    int numLinks = input.nextInt();
    int startNode = input.nextInt();

    Graph g = new Graph(numVertices, numLinks);

    for(int i = 0; i&lt;numLinks; i++){
        g.addEdge(input.nextInt(),input.nextInt());
    }
</code></pre>

<p>I think the problem is in the addEdge function. What am i doing wrong?</p>
