本文整理汇总了Java中com.tinkerpop.blueprints.impls.tg.TinkerGraph类的典型用法代码示例。如果您正苦于以下问题:Java TinkerGraph类的具体用法?Java TinkerGraph怎么用?Java TinkerGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TinkerGraph类属于com.tinkerpop.blueprints.impls.tg包,在下文中一共展示了TinkerGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportFunction
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
private void exportFunction(Vertex vertex) throws IOException
{
executor.execute(() -> {
Graph graph = orientConnector.getNoTxGraphInstance();
try
{
Vertex functionRoot = graph.getVertex(vertex);
Graph subgraph = new TinkerGraph();
copyFunctionNodes(subgraph, functionRoot);
copyFunctionEdges(subgraph, functionRoot);
subgraph.shutdown();
Path out = Paths.get(outputDirectory.toString(), "func" +
functionRoot.getId().toString().split(":")[1] +
"." + format);
writeGraph(subgraph, out);
} catch (IOException e)
{
e.printStackTrace();
} finally
{
graph.shutdown();
}
});
}
示例2: setUp
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
graph = new TinkerGraph();
Vertex S0 = graph.addVertex( "S0" );
Vertex S1 = graph.addVertex( "S1" );
Vertex a = graph.addVertex( "A" );
Vertex b = graph.addVertex( "B" );
Vertex c = graph.addVertex( "C" );
Vertex d = graph.addVertex( "D" );
graph.addEdge( null, S0, a, GraphUtils.EDGE_HOPSTO );
graph.addEdge( null, S1, b, GraphUtils.EDGE_HOPSTO );
graph.addEdge( null, a, b, GraphUtils.EDGE_HOPSTO );
graph.addEdge( null, b, c, GraphUtils.EDGE_HOPSTO );
graph.addEdge( null, b, d, GraphUtils.EDGE_HOPSTO );
// Expect layout
// S0 -> A -> B -> C
// S1 -------^ `-> D
horizontalLayout = new HorizontalLayout();
}
示例3: main
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Please enter a graph name.");
System.err.println("graphs: memory-beta, simpsons, wookieepedia");
System.err
.println("Graph path should be set in the graphs.poperties file.");
System.exit(1);
}
TinkerGraph graph;
try {
graph = SingletonGraph.getInstance().getGraphs().get(args[0]);
Index<Vertex> index = graph.getIndex("verb-idx", Vertex.class);
GremlinPipeline<Iterable<Vertex>, Vertex> pipeline = new GremlinPipeline<Iterable<Vertex>, Vertex>();
pipeline.start(index.get("verbIndex", null)).hasNot(NerdleGraphTransformer.PROPERTY_ISSYNONYM, true);
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
示例4: answerToQuestion
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
public QuestionAnswerResponse answerToQuestion(String question,
TinkerGraph graph) throws InterruptedException,
ConfigurationException {
QuestionAnswerResponse answers = null;
if (question.toLowerCase().contains("who")) {
answers = answerToWho(question, graph);
} else if (question.toLowerCase().contains("which")) {
answers = answerToWhich(question, graph);
} else if (question.toLowerCase().contains("where")) {
answers = answerToWhere(question, graph);
} else if (question.toLowerCase().contains("when")) {
answers = answerToWhen(question, graph);
}
return answers;
}
示例5: SingletonGraph
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
private SingletonGraph() {
try {
propertiesConfiguration = new PropertiesConfiguration(ResourceManager.getResourcePath(File.separator+"graphs.properties"));
} catch (ConfigurationException e) {
e.printStackTrace();
}
String[] graphStrings = propertiesConfiguration.getStringArray("graphs");
String graphsBasePath = propertiesConfiguration.getString("basePath");
graphs = new HashMap<String, TinkerGraph>();
for(String graph: graphStrings){
TinkerGraph g = new TinkerGraph(graphsBasePath+File.separator+graph, TinkerGraph.FileType.GRAPHSON);
g.createKeyIndex(NerdleGraphTransformer.PROPERTY_LEMMA, Vertex.class);
graphs.put(graph, g);
}
}
示例6: testEisteinClause
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testEisteinClause() throws Exception {
TinkerGraph graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
Vertex c = graph.addVertex(null);
Vertex d = graph.addVertex(null);
a.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein");
a.setProperty("ner", "PERSON");
a.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
b.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm");
b.setProperty("ner", "PERSON");
b.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
c.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
c.setProperty("ner", "PERSON");
c.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
d.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born");
d.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
}
示例7: testTraversalPerformance
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testTraversalPerformance() {
TinkerGraph t = TinkerGraphFactory.createTinkerGraph();
FramedGraph f = new FramedGraph(t);
Timer timer = metrics.timer("gremlin");
Context time = timer.time();
for (int count = 0; count < iterations; count++) {
GremlinPipeline g = new GremlinPipeline(t);
g.V().both().both().both().toList();
}
long nanoseconds = time.stop();
System.out.println("Iterate over all GremlinPipeline " + nanoseconds / 1000000);
time = timer.time();
for (int count = 0; count < iterations; count++) {
f.V().both().both().both().toList();
}
nanoseconds = time.stop();
System.out.println("Iterate over all Totorom " + nanoseconds / 1000000);
}
示例8: testSanity
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testSanity() {
Graph g = new TinkerGraph();
FramedGraph fg = new FramedGraph(g);
Person p1 = fg.addVertex(Person.class);
p1.setName("Bryn");
Person p2 = fg.addVertex(Person.class);
p2.setName("Julia");
Knows knows = p1.addKnows(p2);
knows.setYears(15);
Person bryn = fg.V().has("name", "Bryn").next(Person.class);
Assert.assertEquals("Bryn", bryn.getName());
Assert.assertEquals(15, bryn.getKnowsList().get(0).getYears());
Collection<Integer> knowsCollection = fg.V().has("name", "Julia").bothE().property("years", Integer.class).aggregate().cap();
Assert.assertEquals(1, knowsCollection.size());
}
示例9: testJavaTyping
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testJavaTyping() {
Graph g = new TinkerGraph();
FramedGraph fg = new FramedGraph(g, FrameFactory.Default, TypeResolver.Java);
Person p1 = fg.addVertex(Programmer.class);
p1.setName("Bryn");
Person p2 = fg.addVertex(Person.class);
p2.setName("Julia");
Person bryn = fg.V().has("name", "Bryn").next(Person.class);
Person julia = fg.V().has("name", "Julia").next(Person.class);
Assert.assertEquals(Programmer.class, bryn.getClass());
Assert.assertEquals(Person.class, julia.getClass());
}
示例10: testUntypedFrames
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testUntypedFrames() {
Graph g = new TinkerGraph();
FramedGraph fg = new FramedGraph(g);
TVertex p1 = fg.addVertex();
p1.setProperty("name", "Bryn");
TVertex p2 = fg.addVertex();
p2.setProperty("name", "Julia");
TEdge knows = p1.addEdge("knows", p2);
knows.setProperty("years", 15);
TVertex bryn = fg.V().has("name", "Bryn").next();
Assert.assertEquals("Bryn", bryn.getProperty("name"));
Assert.assertEquals(15, bryn.outE("knows").toList().get(0).getProperty("years"));
Collection<Integer> knowsCollection = fg.V().has("name", "Julia").bothE().property("years", Integer.class).aggregate().cap();
Assert.assertEquals(1, knowsCollection.size());
}
示例11: getEdges
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
public Graph getEdges(RelationshipType type, boolean entail, long skip, long limit) {
String query = "MATCH path = (start)-[r:" + type.name() + (entail ? "!" : "") + "]->(end) "
+ " RETURN path "
// TODO: This slows down the query dramatically.
// + " ORDER BY ID(r) "
+ " SKIP " + skip + " LIMIT " + limit;
Graph graph = new TinkerGraph();
TinkerGraphUtil tgu = new TinkerGraphUtil(graph, curieUtil);
Result result;
try {
result = cypherUtil.execute(query);
while (result.hasNext()) {
Map<String, Object> map = result.next();
Path path = (Path) map.get("path");
tgu.addPath(path);
}
} catch (ArrayIndexOutOfBoundsException e) {
// Return and empty graph if the limit is too high...
}
return graph;
}
示例12: setUp
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Before
public void setUp() {
intervals = new IntervalLattice<>(new TinkerGraph());
Interval<Integer> x = new Interval<>(1, Range.closed(9, 12));
Interval<Integer> y = new Interval<>(1, Range.closed(10, 14));
Interval<Integer> z = new Interval<>(1, Range.closed(11, 16));
Interval<Integer> w = new Interval<>(2, Range.closed(1, 2));
// TODO: there's a bug revealed if you swap z and y -- test commutative
intervals.insert(x);
intervals.insert(y);
intervals.insert(z);
intervals.insert(w);
System.out.println(intervals);
}
示例13: convertStringToGraph
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
protected Graph convertStringToGraph( String graphString ) throws KettleValueException {
if ( graphString == null ) {
return null;
}
Graph baseGraph = null;
try {
// GraphSON is a string like JSON, so we should just validate the string is GSON-able
// Before Blueprints 2.4 (which has an ASM conflict with PDI), the only vendor-neutral
// Graph implementation is the TinkerGraph
baseGraph = (Graph) new TinkerGraph();
if ( !Const.isEmpty( graphString ) ) {
GraphSONReader.inputGraph( baseGraph, new ByteArrayInputStream( graphString.getBytes() ) );
}
return baseGraph;
} catch ( UnsupportedEncodingException uee ) {
throw new KettleValueException( uee );
} catch ( IOException ioe ) {
throw new KettleValueException( ioe );
}
}
示例14: testGraphWithCustomData
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
@Test
public void testGraphWithCustomData() throws Exception {
// Create empty graph
Graph graph = new TinkerGraph();
// Add custom data
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
a.setProperty("name", "marko");
b.setProperty("name", "peter");
Edge e = graph.addEdge(null, a, b, "knows");
Vertex inVertex = e.getVertex(IN);
Vertex outVertex = e.getVertex(OUT);
StringBuilder sb = new StringBuilder();
sb.append(outVertex.getProperty("name")).append(" ")
.append("--|").append(e.getLabel()).append("|-->")
.append(" ").append(inVertex.getProperty("name"));
LOG.info(sb.toString());
}
示例15: generateGraph
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入依赖的package包/类
/**
* Generates a graph, as described in the class documentation.
*/
public Graph generateGraph()
{
graph = new TinkerGraph();
addNodes();
addClusters();
addEdges();
return graph;
}