public void adjacencyListConnections(GraphNode<T> a, GraphNode<T> b, int direction,int weight) {//creates connection between two nodes forming the adjacency list.(lists inside lists)

        if (existNode(a) && existNode(b)) {//if a and b exists in the list of graph nodes.
            if (direction == 0 || direction == 1) {// direction param: 1 if it is directed(directed from a to b).
                if (direction == 0) {            //0 if it has links to both sides.(a to b, b to a)
                    //creates bidirectional link
                    //to first direction.

                    GraphNode gr_node = (GraphNode) graph_nodes.get(searchNodePosition(a));
                    List<GraphNode> grphn = gr_node.getNode_graphs();
                    grphn.append(b);
                    gr_node.setNode_graphs(grphn);//adds the node to the adjacency list
                    ((GraphNode) (gr_node)).addLink(b, weight);//makes the link between nodes
                    this.num_aristas += 1;

                    //to the other direction.
                    GraphNode gr_node2 = (GraphNode) graph_nodes.get(searchNodePosition(b));
                    List<GraphNode> grphn2 = gr_node2.getNode_graphs();
                    grphn2.append(a);
                    gr_node2.setNode_graphs(grphn2);//adds the node to the adjacency list
                    ((GraphNode) (gr_node2)).addLink(a, weight);//makes the link between nodes
                    this.num_aristas += 1;

                } else if (direction == 1) {//creates one direction link
                    //to first direction.
                    GraphNode gr_node = (GraphNode) graph_nodes.get(searchNodePosition(a));
                    gr_node.getNode_graphs().append(b);
                    gr_node.setNode_graphs(gr_node.getNode_graphs());
                    ((GraphNode) (gr_node)).addLink(b, weight);
                    this.num_aristas += 1;
                }
            }
        } else {
            System.out.println("graphnode a or graphnode b are not in the list");
        }
    }