当前位置: 首页>>代码示例>>Java>>正文


Java Graph.vertices方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Graph.vertices方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.vertices方法的具体用法?Java Graph.vertices怎么用?Java Graph.vertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.structure.Graph的用法示例。


在下文中一共展示了Graph.vertices方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: smallTest

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
public static void smallTest(Graph graph) {
	Iterator<Vertex> it = graph.vertices();
	int i=0;
	while(i<100 && it.hasNext()) {
		Vertex v = it.next();
		System.out.println(v.id()+"/"+v.property("node"));
		i++;

	}
	
	// Iterate over Edges
	Iterator<Edge> it2 = graph.edges();
	i=0;
	while(i<100 && it2.hasNext()) {
		Edge e = it2.next();
		System.out.println(e);
		i++;
	}
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:20,代码来源:HDTtoGremlin.java

示例2: createProperty

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
public static Property createProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
    final Property baseProperty = attachableProperty.get();
    final Element baseElement = baseProperty.element();
    if (baseElement instanceof Vertex) {
        return Method.createVertexProperty((Attachable) attachableProperty, hostGraph);
    } else if (baseElement instanceof Edge) {
        final Iterator<Edge> edgeIterator = hostGraph.edges(baseElement.id());
        if (edgeIterator.hasNext())
            return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
        throw new IllegalStateException("Could not find edge to create the attachable property on");
    } else { // vertex property
        final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) baseElement).element().id());
        if (vertexIterator.hasNext()) {
            final Vertex vertex = vertexIterator.next();
            final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertex.properties(((VertexProperty) baseElement).key());
            while (vertexPropertyIterator.hasNext()) {
                final VertexProperty<Object> vp = vertexPropertyIterator.next();
                if (ElementHelper.areEqual(vp, baseElement))
                    return vp.property(baseProperty.key(), baseProperty.value());
            }
        }
        throw new IllegalStateException("Could not find vertex property to create the attachable property on");
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:Attachable.java

示例3: getVertex

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
private Vertex getVertex(Graph graph, Object id) {
	Iterator<Vertex> iter = graph.vertices(id);
	if (iter.hasNext()) {
		return iter.next();
	} else {
		return null;
	}
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:9,代码来源:BitsyGraphIT.java

示例4: getVertexProperty

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
    final VertexProperty baseVertexProperty = attachableVertexProperty.get();
    final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
    if (vertexIterator.hasNext()) {
        final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties(baseVertexProperty.key());
        while (vertexPropertyIterator.hasNext()) {
            final VertexProperty vertexProperty = vertexPropertyIterator.next();
            if (ElementHelper.areEqual(vertexProperty, baseVertexProperty))
                return Optional.of(vertexProperty);
        }
    }
    return Optional.empty();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:Attachable.java

示例5: createVertexProperty

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
    final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
    final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
    if (vertexIterator.hasNext()) {
        final VertexProperty vertexProperty = hostGraph.features().vertex().properties().willAllowId(baseVertexProperty.id()) ?
                vertexIterator.next().property(hostGraph.features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value(), T.id, baseVertexProperty.id()) :
                vertexIterator.next().property(hostGraph.features().vertex().getCardinality(baseVertexProperty.key()), baseVertexProperty.key(), baseVertexProperty.value());
        baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
        return vertexProperty;
    }
    throw new IllegalStateException("Could not find vertex to create the attachable vertex property on");
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:Attachable.java

示例6: getVerticesAndNormalizeIfRequired

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
private Iterable<Vertex> getVerticesAndNormalizeIfRequired(final Graph graph) {
    final Iterable<Vertex> vertices;
    if (normalize) {
        vertices = new ArrayList<>();
        final Iterator<Vertex> vertexIterator = graph.vertices();
        while (vertexIterator.hasNext()) {
            ((Collection<Vertex>) vertices).add(vertexIterator.next());
        }
        Collections.sort((List<Vertex>) vertices, Comparators.ELEMENT_COMPARATOR);
    } else
        vertices = IteratorUtils.list(graph.vertices());

    return vertices;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:GraphMLWriter.java

示例7: determineVertexTypes

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
private static Map<String, String> determineVertexTypes(final Graph graph) {
    final Map<String, String> vertexKeyTypes = new HashMap<>();
    final Iterator<Vertex> vertices = graph.vertices();
    while (vertices.hasNext()) {
        final Vertex vertex = vertices.next();
        for (String key : vertex.keys()) {
            if (!vertexKeyTypes.containsKey(key)) {
                vertexKeyTypes.put(key, GraphMLWriter.getStringType(vertex.property(key).value()));
            }
        }
    }

    return vertexKeyTypes;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:GraphMLWriter.java

示例8: approximateGraphsCheck

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
/**
 * Checks sequentially vertices and edges of both graphs. Will check sequentially Vertex IDs, Vertex Properties IDs
 * and values and classes. Then same for edges. To use when serializing a Graph and deserializing the supposedly
 * same Graph.
 */
private boolean approximateGraphsCheck(Graph g1, Graph g2) {
    final Iterator<Vertex> itV = g1.vertices();
    final Iterator<Vertex> itVRead = g2.vertices();

    while (itV.hasNext()) {
        final Vertex v = itV.next();
        final Vertex vRead = itVRead.next();

        // Will only check IDs but that's 'good' enough.
        if (!v.equals(vRead)) {
            return false;
        }

        final Iterator itVP = v.properties();
        final Iterator itVPRead = vRead.properties();
        while (itVP.hasNext()) {
            final VertexProperty vp = (VertexProperty) itVP.next();
            final VertexProperty vpRead = (VertexProperty) itVPRead.next();
            if (!vp.value().equals(vpRead.value())
                    || !vp.equals(vpRead)) {
                return false;
            }
        }
    }

    final Iterator<Edge> itE = g1.edges();
    final Iterator<Edge> itERead = g2.edges();

    while (itE.hasNext()) {
        final Edge e = itE.next();
        final Edge eRead = itERead.next();
        // Will only check IDs but that's good enough.
        if (!e.equals(eRead)) {
            return false;
        }

        final Iterator itEP = e.properties();
        final Iterator itEPRead = eRead.properties();
        while (itEP.hasNext()) {
            final Property ep = (Property) itEP.next();
            final Property epRead = (Property) itEPRead.next();
            if (!ep.value().equals(epRead.value())
                    || !ep.equals(epRead)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:55,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例9: getVertex

import org.apache.tinkerpop.gremlin.structure.Graph; //导入方法依赖的package包/类
public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
    final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.get().id());
    return vertexIterator.hasNext() ? Optional.of(vertexIterator.next()) : Optional.empty();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:Attachable.java


注:本文中的org.apache.tinkerpop.gremlin.structure.Graph.vertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。