I've a directed unweighted graph. Number of nodes and all links between nodes are given. I tried to do the task with array of vectors but java doesn't support it. ArrayList and Vectors support random access iterators but unable to do it in java as I'm new to it. I don't want to use 2-Dimensional matrix for it. I want to implement it as an array of N given nodes, where each node has a list of those nodes which are connected to it. Please somebody provide a pseudocode or anything which could help me. For Example, a graph is given as
5
3 4
4 2
1 5
4 3
1 3
2 5
here 5 nodes numbered 1 to 5 are given. Following are the directed edges from first node to second node. I want to represent it as adjacency list of graph. Could anybody give the implementation of it?