本文整理汇总了Java中org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution类的典型用法代码示例。如果您正苦于以下问题:Java PowerLawDistribution类的具体用法?Java PowerLawDistribution怎么用?Java PowerLawDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PowerLawDistribution类属于org.apache.tinkerpop.gremlin.algorithm.generator包,在下文中一共展示了PowerLawDistribution类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterLoadGraphWith
import org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution; //导入依赖的package包/类
@Override
protected void afterLoadGraphWith(final Graph g) throws Exception {
ids.clear();
final int numVertices = 10000;
final Random r = new Random(854939487556l);
for (int i = 0; i < numVertices; i++) {
final Vertex v = g.addVertex("oid", i, "name", RandomStringUtils.randomAlphabetic(r.nextInt(1024)));
ids.add(v.id());
}
final Distribution inDist = new PowerLawDistribution(2.3);
final Distribution outDist = new PowerLawDistribution(2.8);
final DistributionGenerator generator = DistributionGenerator.build(g)
.label("knows")
.seedGenerator(r::nextLong)
.outDistribution(outDist)
.inDistribution(inDist)
.edgeProcessor(e -> e.<Double>property("weight", r.nextDouble()))
.expectedNumEdges(numVertices * 3).create();
edgeCount = generator.generate();
}
示例2: shouldWriteSampleForGremlinServer
import org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution; //导入依赖的package包/类
@Test
public void shouldWriteSampleForGremlinServer() throws IOException {
final Graph g = TinkerGraph.open();
IntStream.range(0, 10000).forEach(i -> g.addVertex("oid", i));
DistributionGenerator.build(g)
.label("knows")
.seedGenerator(() -> 987654321L)
.outDistribution(new PowerLawDistribution(2.1))
.inDistribution(new PowerLawDistribution(2.1))
.expectedNumEdges(100000).create().generate();
final OutputStream os = new FileOutputStream(tempPath + "sample.kryo");
GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, g);
os.close();
}
示例3: shouldWriteSampleForGremlinServer
import org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution; //导入依赖的package包/类
@Test
public void shouldWriteSampleForGremlinServer() throws IOException {
final Graph g = TinkerGraph.open();
IntStream.range(0, 10000).forEach(i -> g.addVertex("oid", i));
DistributionGenerator.build(g)
.label("knows")
.seedGenerator(() -> 987654321l)
.outDistribution(new PowerLawDistribution(2.1))
.inDistribution(new PowerLawDistribution(2.1))
.expectedNumEdges(100000).create().generate();
final OutputStream os = new FileOutputStream(tempPath + "sample.kryo");
GryoWriter.build().create().writeGraph(os, g);
os.close();
}