private static void createGraph(Collection<Triple> tc, int triples, Long seed){
Random rnd = new Random();
if(seed != null){
rnd.setSeed(seed);
}
LiteralFactory lf = LiteralFactory.getInstance();
//randoms are in the range [0..3]
double l = 1.0; //literal
double i = l / 3; //int
double d = l * 2 / 3;//double
double b = 2.0;//bNode
double nb = b - (l * 2 / 3); //create new bNode
double random;
NonLiteral subject = null;
UriRef predicate = null;
List<UriRef> predicateList = new ArrayList<UriRef>();
predicateList.add(RDF.first);
predicateList.add(RDF.rest);
predicateList.add(RDF.type);
predicateList.add(RDFS.label);
predicateList.add(RDFS.comment);
predicateList.add(RDFS.range);
predicateList.add(RDFS.domain);
predicateList.add(FOAF.name);
predicateList.add(FOAF.nick);
predicateList.add(FOAF.homepage);
predicateList.add(FOAF.age);
predicateList.add(FOAF.depiction);
String URI_PREFIX = "http://www.test.org/bigGraph/ref";
Language DE = new Language("de");
Language EN = new Language("en");
Iterator<UriRef> predicates = predicateList.iterator();
List<BNode> bNodes = new ArrayList<BNode>();
bNodes.add(new BNode());
for (int count = 0; tc.size() < triples; count++) {
random = rnd.nextDouble() * 3;
if (random >= 2.5 || count == 0) {
if (random <= 2.75) {
subject = new UriRef(URI_PREFIX + count);
} else {
int rndIndex = (int) ((random - 2.75) * bNodes.size() / (3.0 - 2.75));
subject = bNodes.get(rndIndex);
}
}
if (random > 2.0 || count == 0) {
if (!predicates.hasNext()) {
Collections.shuffle(predicateList,rnd);
predicates = predicateList.iterator();
}
predicate = predicates.next();
}
if (random <= l) { //literal
if (random <= i) {
tc.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(count)));
} else if (random <= d) {
tc.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(random)));
} else {
PlainLiteral text;
if (random <= i) {
text = new PlainLiteralImpl("Literal for " + count);
} else if (random <= d) {