Creating a graph in Java I'm building an application that implements the A* algorithm to calculate a route between two rooms. I am trying to create a graph which the algorithm can operate on and I am not sure if this is the right way to do it.

Here's what I've done so far:

Vect2.java:

package myalgorithm;

public class Vect2 {

    private int x;
    private int y;


    public Vect2(int x,int y ){

        this.x = x;
        this.y = y;

        }

}


Node.java

package myalgorithm;




public class Node {

    Node parent;
    Vect2 vector;
    public int x;
    public int y;

    public double f;
    public double g;
    public double h;


    public Node( int x,int y,Node parent, double g,double h){

        this.x = x;
        this.y = y;
        this.parent= parent;
        this.g = g;
        this.h = h;
        this.f= this.g + this.h;

    }
}


NodeGraph.java

package myalgorithm;
import java.util.Arrays;

public class NodeGraph {

    Node a = new Node(88,623,null,0,0);
    Node b = new Node(727,627,null,0,0);
    Node c = new Node(723,93,null,0,0);
    Node d = new Node(90,92,null,0,0);
    Node e = new Node(94,349,null,0,0);
    Node f = new Node(397,358,null,0,0);
    Node g = new Node(722,339,null,0,0);
    Node[] arr = new Node[7];


public NodeGraph init(){


    arr[0]= a;
    arr[0]= b;
    arr[0]= c;
    arr[0]= d;
    arr[0]= e;
    arr[0]= f;
    arr[0]= g;

    return this;
}
public void createMatrx(){
boolean[][] matrix = new boolean[7][];
for (int i=0; i&lt;matrix.length; i++) matrix[i] = new boolean[7];

int nodeA = Arrays.binarySearch(arr, a);
int nodeB = Arrays.binarySearch(arr, b);
int nodeC = Arrays.binarySearch(arr, c);
int nodeD = Arrays.binarySearch(arr, d);
int nodeE = Arrays.binarySearch(arr, e);
int nodeF = Arrays.binarySearch(arr, f);
int nodeG = Arrays.binarySearch(arr, g);

matrix[nodeA][nodeB] = true;
matrix[nodeA][nodeE] = true;
matrix[nodeB][nodeA] = true;
matrix[nodeB][nodeG] = true;
// A is connected to D
matrix[nodeC][nodeG] = true;
matrix[nodeC][nodeD] = true;
// B is connected to D
matrix[nodeD][nodeC] = true;
matrix[nodeD][nodeE] = true;
matrix[nodeE][nodeD] = true;
// C is connected to D
matrix[nodeE][nodeF] = true;
matrix[nodeE][nodeA] = true;
matrix[nodeF][nodeE] = true;
matrix[nodeE][nodeG] = true;

matrix[nodeG][nodeF] = true;
matrix[nodeE][nodeB] = true;
matrix[nodeE][nodeC] = true;

matrix[nodeD][nodeC] = true;
}
}
In general, you have some problems being consisten in your coding. 

1) Formatting: 

In your NodeGraph class you are not consistent in your indentation. Your createMatrx (which has a typo and should be called createMatrix) you are not using any indentation. 

2) Access modifiers: 

In your class Node2 you set your members private, as expected. 

In your class Node you don't specifically set the access modifier as private for some members, and you set them explicitly publbic for others. I would expect all members to be private. 

3) Naming: 

Single character variable names are not very descriptive. Name your variables according to their purpose.