What are the uses of the java code in: org.apache.commons.collections15.Factory
- Is there documentation (I cannot find anything useful)
- How do I use this to instantiate objects of type:
Factory<Integer>
,Factory<String>
in the constructor of the BarabasiAlbertGenerator in the Java Jung graph package? - How can I get a properly functioning BarabasiAlbertGenerator.
This is the code I have, and it only outputs a single vertex.
Factory<Graph<String, Integer>> graphFactory = SparseGraph.getFactory();
Integer[] ints = {1};
String[] strs = {"12"};
Class[] typesStr = {String.class};
Class[] typesInt = {int.class};
Factory<String> vertexFactory = InstantiateFactory.getInstance(String.class, typesStr, strs);
Factory<Integer> edgeFactory = InstantiateFactory.getInstance(Integer.class, typesInt, ints);
HashSet<String> seedVertices = new HashSet();
for(int i = 0; i < 10; i++)
{
seedVertices.add("v"+i);
}
BarabasiAlbertGenerator<String, Integer> barabasiGen = new
BarabasiAlbertGenerator<String,Integer>(graphFactory, vertexFactory,
edgeFactory, seedVertices.size(), 1, seedVertices);
Graph g = barabasiGen.create();
I think my issue has something to do with my vertexFactory and edgeFactory. To me it seems like my vertexFactory can only create vertices with the value 12, and my edgeFactory can only create edges with the value 1. Therefore, the graph will only have 1 vertice with value 12. Is this reasoning accurate?