本文整理汇总了Java中com.tinkerpop.blueprints.impls.tg.TinkerGraph.addVertex方法的典型用法代码示例。如果您正苦于以下问题:Java TinkerGraph.addVertex方法的具体用法?Java TinkerGraph.addVertex怎么用?Java TinkerGraph.addVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tinkerpop.blueprints.impls.tg.TinkerGraph
的用法示例。
在下文中一共展示了TinkerGraph.addVertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: createArgumentVertex
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
private static Vertex createArgumentVertex(NerdleArg nerdleArg,
TinkerGraph graph) {
Vertex vertex = graph.addVertex(null);
vertex.setProperty(PROPERTY_TEXT, nerdleArg.getText());
vertex.setProperty(PROPERTY_NER, nerdleArg.getNer());
vertex.setProperty(PROPERTY_CLAUSE_TYPE, VALUE_CLAUSE_TYPE_ARGUMENT);
return vertex;
}
示例4: createSubjectVertex
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
private static Vertex createSubjectVertex(NerdleSubject nerdleSubject,
TinkerGraph graph) {
Vertex vertex = graph.addVertex(null);
vertex.setProperty(PROPERTY_TEXT, nerdleSubject.getText());
vertex.setProperty(PROPERTY_CLAUSE_TYPE, VALUE_CLAUSE_TYPE_SUBJECT);
return vertex;
}
示例5: createPredicateVertex
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
private static Vertex createPredicateVertex(
NerdlePredicate nerdlePredicate, String sentence, String source,
double confidence, TinkerGraph graph) {
Vertex vertex = graph.addVertex(null);
vertex.setProperty(PROPERTY_VERBTEXT, nerdlePredicate.getText());
String lemma = nerdlePredicate.getLemma();
if(lemma == null || lemma.isEmpty()){
vertex.setProperty(PROPERTY_LEMMA, nerdlePredicate.getText());
} else {
vertex.setProperty(PROPERTY_LEMMA, lemma);
}
vertex.setProperty(PROPERTY_ISSYNONYM, false);
vertex.setProperty(PROPERTY_CLAUSE_TYPE, VALUE_CLAUSE_TYPE_PREDICATE);
vertex.setProperty(PROPERTY_SENTENCE, sentence);
vertex.setProperty(PROPERTY_SOURCE, source);
vertex.setProperty(PROPERTY_CONFIDENCE, confidence);
for (String synonym : nerdlePredicate.getSynonyms()) {
Vertex synonymVertex = graph.addVertex(null);
synonymVertex.setProperty(PROPERTY_LEMMA, synonym);
synonymVertex.setProperty(PROPERTY_CLAUSE_TYPE,
VALUE_CLAUSE_TYPE_PREDICATE);
synonymVertex.setProperty(PROPERTY_ISSYNONYM, true);
graph.addEdge(null, vertex, synonymVertex, "hasSynonym");
}
return vertex;
}
示例6: testAPI
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testAPI() throws Exception {
TinkerGraph graph = new TinkerGraph();
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");
e.setProperty("since", 2006);
}
示例7: testIndexPerformance
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testIndexPerformance() {
TinkerGraph t = TinkerGraphFactory.createTinkerGraph();
t.createKeyIndex("name", Vertex.class);
FramedGraph f = new FramedGraph(t);
Timer timer = metrics.timer("gremlin");
Vertex lastVertex = null;
for (int count = 0; count < iterations; count++) {
Vertex v = t.addVertex(null);
v.setProperty("name", "name" + count);
if (lastVertex != null) {
v.addEdge("test", lastVertex);
}
lastVertex = v;
}
Context time = timer.time();
for (int count = 0; count < iterations; count++) {
GremlinPipeline g = new GremlinPipeline(t);
g.V("name", "name" + count).both().both().both().toList();
}
long nanoseconds = time.stop();
System.out.println("Iterate with index lookup GremlinPipeline " + nanoseconds / 1000000);
time = timer.time();
for (int count = 0; count < iterations; count++) {
f.V().has("name", "name" + count).both().both().both().toList();
}
nanoseconds = time.stop();
System.out.println("Iterate with index lookup Totorom " + nanoseconds / 1000000);
}
示例8: resultToGraph
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
public Graph resultToGraph(Result result) {
graph = new TinkerGraph();
while (result.hasNext()) {
Map<String, Object> map = result.next();
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
String key = entry.getKey();
if (null == value) {
continue;
} else if (value instanceof PropertyContainer) {
addElement((PropertyContainer) value);
} else if (value instanceof Path) {
for (PropertyContainer container : (Path) value) {
addElement(container);
}
} else if (value instanceof SeqWrapper) {
for (Object thing : (SeqWrapper<?>) value) {
if (thing instanceof PropertyContainer) {
addElement((PropertyContainer) thing);
}
}
} else if (value instanceof Boolean) {
// generates a lonely node which contains the result
Vertex vertex = graph.addVertex(key);
vertex.setProperty(key, value);
vertex.setProperty(NodeProperties.LABEL, "Boolean result");
vertex.setProperty(CommonProperties.IRI, key);
} else {
logger.warning("Not converting " + value.getClass() + " to tinker graph");
}
}
}
return graph;
}
示例9: graphsAreMerged
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void graphsAreMerged() {
TinkerGraph graph1 = new TinkerGraph();
Vertex g1v1 = graph1.addVertex(0);
Vertex g1v2 = graph1.addVertex(1);
Edge g1e1 = graph1.addEdge(0, g1v1, g1v2, "test");
TinkerGraph graph2 = new TinkerGraph();
Vertex g2v1 = graph2.addVertex(1);
Vertex g2v2 = graph2.addVertex(2);
Edge g2e1 = graph1.addEdge(1, g2v1, g2v2, "test2");
TinkerGraphUtil tgu = new TinkerGraphUtil(graph1, curieUtil);
Graph graph = tgu.combineGraphs(graph2);
assertThat(graph.getVertices(), containsInAnyOrder(g1v1, g1v2, g2v2));
assertThat(graph.getEdges(), containsInAnyOrder(g1e1, g2e1));
}
示例10: primitivePropertiesAreReturned
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void primitivePropertiesAreReturned() {
TinkerGraph graph = new TinkerGraph();
Vertex v = graph.addVertex(1);
assertThat(TinkerGraphUtil.getProperty(v, "foo", String.class), is(Optional.<String>empty()));
v.setProperty("foo", "bar");
assertThat(TinkerGraphUtil.getProperty(v, "foo", String.class), is(Optional.of("bar")));
}
示例11: collectionsAreReturned
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void collectionsAreReturned() {
TinkerGraph graph = new TinkerGraph();
Vertex v = graph.addVertex(1);
assertThat(TinkerGraphUtil.getProperties(v, "foo", String.class), is(empty()));
v.setProperty("foo", "bar");
assertThat(TinkerGraphUtil.getProperties(v, "foo", String.class), contains("bar"));
v.setProperty("foo", newHashSet("bar", "baz"));
assertThat(TinkerGraphUtil.getProperties(v, "foo", String.class), containsInAnyOrder("bar", "baz"));
v.setProperty("foo", new String[] {"bar", "baz"});
assertThat(TinkerGraphUtil.getProperties(v, "foo", String.class), containsInAnyOrder("bar", "baz"));
}
示例12: propertiesProject
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void propertiesProject() {
TinkerGraph graph = new TinkerGraph();
Vertex v = graph.addVertex(1);
v.setProperty(CommonProperties.IRI, "http://x.org/a");
v.setProperty("foo", "fizz");
v.setProperty("bar", "baz");
TinkerGraphUtil tgu = new TinkerGraphUtil(graph, curieUtil);
tgu.project(newHashSet("foo"));
assertThat(v.getPropertyKeys(), containsInAnyOrder("foo", CommonProperties.IRI));
}
示例13: allPropertiesProject
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void allPropertiesProject() {
TinkerGraph graph = new TinkerGraph();
Vertex v = graph.addVertex(1);
v.setProperty(CommonProperties.IRI, "http://x.org/a");
v.setProperty("foo", "fizz");
v.setProperty("bar", "baz");
TinkerGraphUtil tgu = new TinkerGraphUtil(graph, curieUtil);
tgu.project(newHashSet("*"));
assertThat(v.getPropertyKeys(), containsInAnyOrder("foo", "bar", CommonProperties.IRI));
}
示例14: setup
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Before
public void setup() {
TinkerGraph graph = new TinkerGraph();
v1 = graph.addVertex(0);
v2 = graph.addVertex(1);
v1.setProperty(CommonProperties.IRI, "foo");
v1.setProperty("foo", "bar");
e = graph.addEdge(0, v1, v2, "test");
e.setProperty("foo", 1);
ArrayPropertyTransformer.transform(graph);
}
示例15: testMultipleClauses
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testMultipleClauses() 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);
graph.addEdge(null, d, a, "");
graph.addEdge(null, d, b, "");
graph.addEdge(null, d, c, "");
Vertex aX = graph.addVertex(null);
Vertex bX = graph.addVertex(null);
Vertex cX = graph.addVertex(null);
Vertex dX = graph.addVertex(null);
aX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein X");
aX.setProperty("ner", "PERSON");
aX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
bX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm X");
bX.setProperty("ner", "PERSON");
bX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
cX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
cX.setProperty("ner", "PERSON X");
cX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
dX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born X");
dX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
graph.addEdge(null, dX, aX, "");
graph.addEdge(null, dX, bX, "");
graph.addEdge(null, dX, cX, "");
}