本文整理了Java中com.tinkerpop.blueprints.Vertex
类的一些代码示例,展示了Vertex
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex
类的具体详情如下:
包路径:com.tinkerpop.blueprints.Vertex
类名称:Vertex
[英]A vertex maintains pointers to both a set of incoming and outgoing edges. The outgoing edges are those edges for which the vertex is the tail. The incoming edges are those edges for which the vertex is the head. Diagrammatically, ---inEdges---> vertex ---outEdges--->.
[中]顶点维护指向一组传入边和传出边的指针。输出边是顶点为尾部的边。传入边是顶点为头部的边。从图表上看,--inEdges-->vertex--outEdges-->。
代码示例来源:origin: gentics/mesh
private void migrateProperty(Vertex vertex, String oldPropertyKey, String newPropertyKey) {
log.info("Migrating vertex: " + vertex.getId());
String value = vertex.getProperty(oldPropertyKey);
vertex.removeProperty(oldPropertyKey);
if (value != null) {
vertex.setProperty(newPropertyKey, value);
}
}
代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung
public boolean isSuccessor(final Vertex outVertex, final Vertex inVertex) {
for (final Edge edge : outVertex.getEdges(Direction.OUT)) {
if (edge.getVertex(Direction.IN).equals(inVertex))
return true;
}
return false;
}
代码示例来源:origin: SciGraph/SciGraph
@Override
public String transform(Vertex vertex) {
String label = "";
if (vertex.getPropertyKeys().contains(NodeProperties.LABEL)) {
Object labels = vertex.getProperty(NodeProperties.LABEL);
if (labels.getClass().isArray()) {
label = " (" + ((String[])labels)[0] + ")";
} else {
label = " (" + vertex.getProperty(NodeProperties.LABEL) + ")";
}
}
// TODO: add curies
/*if (vertex.getPropertyKeys().contains(CommonProperties.FRAGMENT)) {
return (String) vertex.getProperty(CommonProperties.FRAGMENT) + label;
} else {*/
return (String) vertex.getProperty(CommonProperties.IRI) + label;
//}
}
};
代码示例来源:origin: pentaho/pentaho-kettle
DictionaryConst.NODE_TYPE_STEP_PROPERTY, (String) targetTemplateStepVertex.getProperty(
DictionaryConst.PROPERTY_LOGICAL_ID ), targetTemplateStepName + ":"
+ targetTemplateStepAttr.getAttributeKey(), null );
.append( targetTemplateStepName ).append( ": " ).append( targetTemplateStepAttr.getAttributeKey() );
verboseProperties.add( mappingKey );
stepVertex.setProperty( mappingKey, mapping.toString() );
getMetaverseBuilder().addLink( sourceStepField, DictionaryConst.LINK_INPUTS, stepVertex );
final Vertex derivedField = findFieldVertex( parentTransMeta, stepVertex.getProperty(
DictionaryConst.PROPERTY_NAME ).toString(),
sourceStepField.getProperty( DictionaryConst.PROPERTY_NAME ).toString() );
if ( derivedField != null ) {
getMetaverseBuilder().addLink( sourceStepField, DictionaryConst.LINK_DERIVES, derivedField );
stepVertex.setProperty( DictionaryConst.PROPERTY_VERBOSE_DETAILS, StringUtils.join( verboseProperties, "," ) );
代码示例来源:origin: gentics/mesh
private Vertex findBinary(String hash, Vertex binaryRoot) {
for (Vertex binary : binaryRoot.getVertices(OUT, "HAS_BINARY")) {
String foundHash = binary.getProperty(NEW_HASH_KEY);
if (foundHash.equals(hash)) {
return binary;
}
}
return null;
}
代码示例来源:origin: edu.jhuapl.tinkerpop/blueprints-accumulo-graph
public BaseEdgeMutator(Edge edge) {
this(edge.getId().toString(),
edge.getVertex(Direction.OUT).getId().toString(),
edge.getVertex(Direction.IN).getId().toString(),
edge.getLabel());
}
public BaseEdgeMutator(String id, String outVertexId, String inVertexId, String label) {
代码示例来源:origin: iTransformers/netTransformer
private void mergeEdge(Graph graph1, Edge edge2) {
Edge edge1 = graph1.getEdge(edge2.getId());
if (edge1 == null) {
Vertex outVertex1 = graph1.getVertex(edge2.getVertex(Direction.OUT).getId());
Vertex outVertex2 = graph1.getVertex(edge2.getVertex(Direction.IN).getId());
edge1 = graph1.addEdge(edge2.getId(), outVertex1, outVertex2, edge2.getLabel());
for (String key2 : edge2.getPropertyKeys()) {
edge1.setProperty(key2,edge2.getProperty(key2));
}
} else {
Set<String> keys1 = edge1.getPropertyKeys();
Set<String> keys2 = edge2.getPropertyKeys();
for (String key2 : keys2) {
if (keys1.contains(key2)) {
MergeConflictResolver conflictResolver = getEdgeConflictResolver(key2);
Object merge = conflictResolver.resolveConflict(edge1.getProperty(key2), edge2.getProperty(key2));
edge1.setProperty(key2, merge);
} else {
edge1.setProperty(key2, edge2.getProperty(key2));
}
}
}
}
代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core
/**
* Copy the vertex/edges of one graph over to another graph.
* The id of the elements in the from graph are attempted to be used in the to graph.
* This method only works for graphs where the user can control the element ids.
*
* @param from the graph to copy from
* @param to the graph to copy to
*/
public static void copyGraph(final Graph from, final Graph to) {
for (final Vertex fromVertex : from.getVertices()) {
final Vertex toVertex = to.addVertex(fromVertex.getId());
ElementHelper.copyProperties(fromVertex, toVertex);
}
for (final Edge fromEdge : from.getEdges()) {
final Vertex outVertex = to.getVertex(fromEdge.getVertex(Direction.OUT).getId());
final Vertex inVertex = to.getVertex(fromEdge.getVertex(Direction.IN).getId());
final Edge toEdge = to.addEdge(fromEdge.getId(), outVertex, inVertex, fromEdge.getLabel());
ElementHelper.copyProperties(fromEdge, toEdge);
}
}
}
代码示例来源:origin: gentics/mesh
private void migrateContainer(Vertex nodeContainer) {
Iterator<Edge> it = nodeContainer.getEdges(OUT, "HAS_LANGUAGE").iterator();
if (!it.hasNext()) {
// We skip containers which have no language set. Those need to be cleaned using the consistency check.
return;
}
Edge languageEdge = it.next();
String languageTag = languageEdge
.getVertex(IN).getProperty("languageTag");
nodeContainer.setProperty("languageTag", languageTag);
languageEdge.remove();
}
代码示例来源:origin: org.jboss.windup.legacy.application/grapher
private void writeGraphNodes(OutputStream os) throws IOException {
//iterate the nodes.
for(Vertex vertex : graph.getVertices()) {
String id = ""+vertex.getId().hashCode();
String label = vertex.getProperty(vertexLabelProperty);
if(StringUtils.isBlank(label)) {
label = vertex.toString();
}
writeGraphNode(id, label, os);
}
}
代码示例来源:origin: apache/incubator-atlas
@Override
public Boolean compute(Edge edge) {
String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN));
return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag");
}
}));
代码示例来源:origin: iTransformers/netTransformer
private GraphmlNode vertexToNode(Vertex vertex){
GraphmlNode node = new GraphmlNode(vertex.getId().toString(),vertex.getId().toString());
Map<String, String> graphmlNodeData = new HashMap<>();
Set<String> keys = vertex.getPropertyKeys();
for (String key : keys) {
graphmlNodeData.put(key,vertex.getProperty(key));
}
node.setGraphmlNodeData(graphmlNodeData);
return node;
}
代码示例来源:origin: SciGraph/SciGraph
void addCuries(Graph graph) {
for (Vertex vertex: graph.getVertices()) {
String iri = (String)vertex.getProperty(CommonProperties.IRI);
Optional<String> curie = curieUtil.getCurie(iri);
if (curie.isPresent()) {
vertex.setProperty(CommonProperties.CURIE, curie.get());
}
}
}
代码示例来源:origin: fr.inria.atlanmod.neoemf/neoemf-data-blueprints-core
/**
* Updates the containment identified by its {@code name} between the {@code parentVertex} and the {@code
* childVertex}.
*
* @param localName the name of the property identifying the reference (parent -> child)
* @param parentVertex the parent vertex
* @param childVertex the child vertex
*/
private static void updateContainment(final String localName, final Vertex parentVertex, final Vertex childVertex) {
for (Edge edge : childVertex.getEdges(Direction.OUT, CONTAINER)) {
edge.remove();
}
Edge edge = childVertex.addEdge(CONTAINER, parentVertex);
edge.setProperty(CONTAINING_FEATURE, localName);
}
代码示例来源:origin: fr.lirmm.graphik/graal-store-blueprints
private static Atom vertexToAtom(Vertex vertex) {
Iterator<Edge> it = vertex.getEdges(Direction.OUT, "predicate")
.iterator();
Vertex predicateVertex = it.next().getVertex(Direction.IN);
Predicate p = vertexToPredicate(predicateVertex);
Term[] terms = new Term[p.getArity()];
for (Edge e : vertex.getEdges(Direction.OUT, "term")) {
Vertex t = e.getVertex(Direction.IN);
terms[(Integer) e.getProperty("index")] = vertexToTerm(t);
}
return new DefaultAtom(p, terms);
}
代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung
public boolean addVertex(final Vertex vertex) {
if (null != graph.getVertex(vertex.getId()))
graph.addVertex(vertex.getId());
return true;
}
代码示例来源:origin: fr.lirmm.graphik/graal-store-blueprints
@Override
public boolean add(Atom atom) {
Vertex atomVertex = graph.addVertex(null);
atomVertex.setProperty("class", "atom");
atomVertex.setProperty("predicate",
predicateToString(atom.getPredicate()));
Vertex predicateVertex = this.add(atom.getPredicate());
this.graph.addEdge(null, atomVertex, predicateVertex, "predicate");
int i = 0;
for (Term t : atom) {
atomVertex.setProperty("term" + i, termToString(t));
Vertex termVertex = this.add(t);
Edge e = graph.addEdge(null, atomVertex, termVertex, "term");
e.setProperty("index", i++);
}
return true;
}
代码示例来源:origin: gentics/mesh
private void updateLists(Vertex container, Map<String, JsonObject> fieldMap) {
for (Vertex listElement: container.getVertices(Direction.OUT, HAS_LIST)) {
String fieldName = listElement.getProperty(FIELD_KEY);
if (fieldMap.containsKey(fieldName) && NUMBER_TYPE.equals(fieldMap.get(fieldName).getString(FIELD_LIST_TYPE_KEY))) {
listElement.getPropertyKeys().stream()
.filter(k -> k.startsWith(ITEM_PREFIX))
.forEach(k -> updateProperty(k, listElement));
}
}
}
代码示例来源:origin: SciGraph/SciGraph
@Test
public void curiesAreAdded() {
Vertex v = graph.addVertex(null);
v.setProperty(CommonProperties.IRI, "http://x.org/foo");
adder.addCuries(graph);
assertThat((String)v.getProperty(CommonProperties.CURIE), is("x:foo"));
}
代码示例来源:origin: gentics/mesh
private void migrateEdge(Edge edge, String newLabel, boolean reverseOrder) {
Vertex in = edge.getVertex(IN);
Vertex out = edge.getVertex(OUT);
if (reverseOrder) {
out.addEdge(newLabel, in);
} else {
in.addEdge(newLabel, out);
}
edge.remove();
}
内容来源于网络,如有侵权,请联系作者删除!