I want to create a program that creates a graph (to be specific a program graph), which stores values at nodes and also stores what other nodes each individual nodes are connected to.
I am thinking of doing this using linked list. Is this the right way to go about it? Any other advice would be greatly appreciated.
For the most part it’s a good idea to model your graph with an adjacency list. There are probably existing frameworks to do this, but if you’re interested in the representation as an exercise, you generally want two things. First, a HashMap containing all of your nodes, the node label for your node can be the key, the node itself is the value.
The Java API documents HashMaps here.
In each node object, you’ll want a list of nodes that are adjacent to that node. This is best done with an ArrayList, which is documented here.
Here’s how it might be organized.
Most algorithms you’d want to run on a graph will run well on this representation.