Java Node class for a Graph I'm using ArrayList&lt;Nodes&gt; to store adjacent nodes, and ArrayList&lt;Integer&gt; to store the corresponding weights of the vertices. Is this efficient if I only use it for small inputs? Is it efficient for large inputs as well?

class Node {
    public ArrayList&lt;Node&gt; adjacent = new ArrayList&lt;Node&gt;();
    public ArrayList&lt;Integer&gt; weights = new ArrayList&lt;Integer&gt;();
    boolean visited;
}
Is this efficient if I only use it for small inputs?


For small inputs, anything is efficient. 
For big data, having each Node as such a large object would be inefficient.
I depends what kind of actions you would do over the graph. If you access it sequentially, there can be also a linked implementation like:

class LinkedNode {
    public Node firstChild;   
    public Node nextSibling;   
    boolean visited;
}


Here's an alternative, without objects but with arrays instead:

int[] edgeWeights;
int[] edgeIndicies;


At the begin, edgeIndicies will have values [0,1,2,...n].
Sorting the weights, you move the indicies instead, so if the indicies are the following:
[5,7,9,...] you know edgeWeights[5] is the smallest, edgeWeights[7] is the second smallest, ...etc.