I'm just starting out with Java and have some fairly basic questions about sets. I want to create a class called DirectedGraph which has two attributes, a set of vertices and a set of edges. What would be the best data structure to use for these sets? It seems Java has several implementations of sets and I would probably just want to use the most basic, featureless kind.
Also, when I try to set the attributes vertices
and edges
I get errors like "Set cannot be resolved by a type" or "Syntax error, insert "Dimensions" to complete Reference Type". Here is some code along with other things I tried commented out:
import java.util.Collections;
public class DirectedGraph {
private Set<> vertices;
// here are some other guesses that also didn't work:
// private Set<int[]> vertices;
// private Set<Integer> vertices;
// private Set<Integer> vertices = new HashSet<Integer>();
}
What is going on with these errors?
Edit:
And if I wanted a constructor that took no arguments but initialized the vertices
and edges
sets as empty, how would I do this?