當前位置: 首頁>>代碼示例>>Java>>正文


Java Vertex.edges方法代碼示例

本文整理匯總了Java中org.apache.tinkerpop.gremlin.structure.Vertex.edges方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertex.edges方法的具體用法?Java Vertex.edges怎麽用?Java Vertex.edges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.tinkerpop.gremlin.structure.Vertex的用法示例。


在下文中一共展示了Vertex.edges方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSubjectStatements

import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
private CloseableIteration<? extends Statement, SailException> getSubjectStatements(final Resource subject) {
    // assuming all edges are statements
    Vertex vertex = getVertexByValue(subject);
    Iterator<Edge> edges = null == vertex
            ? Collections.emptyIterator()
            : vertex.edges(Direction.OUT);
    return toStatements(edges);
}
 
開發者ID:joshsh,項目名稱:graphsail,代碼行數:9,代碼來源:DataStore.java

示例2: getObjectStatements

import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
private CloseableIteration<? extends Statement, SailException> getObjectStatements(final Value object) {
    // assuming all edges are statements
    Vertex vertex = getVertexByValue(object);
    Iterator<Edge> edges = null == vertex
            ? Collections.emptyIterator()
            : vertex.edges(Direction.IN);
    return toStatements(edges);
}
 
開發者ID:joshsh,項目名稱:graphsail,代碼行數:9,代碼來源:DataStore.java

示例3: edgeExists

import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
boolean edgeExists(final Vertex outV, final Vertex inV, final String label, final String context) {
    Iterator<Edge> edges = outV.edges(Direction.OUT, label);
    while (edges.hasNext()) {
        Edge next = edges.next();
        if (!next.inVertex().equals(inV)) continue;
        if (contextEquals(context, next)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:joshsh,項目名稱:graphsail,代碼行數:12,代碼來源:DataStore.java

示例4: main

import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

		Configuration conf = new PropertiesConfiguration( getRelativeResourcePath( "titan-cassandra-es.properties" ) );
		// start elastic search on startup
		Node node = new NodeBuilder().node();
		
		TitanGraph graph = TitanFactory.open(conf);
		/* Comment if you do not want to reload the graph every time */
		graph.close();
		TitanCleanup.clear(graph);
		graph = TitanFactory.open(conf);
		GraphOfTheGodsFactory.load(graph);
		/* graph loaded  */
		
		// create own indexes
		TitanManagement mgmt = graph.openManagement();
		PropertyKey name = mgmt.getPropertyKey("name");
		PropertyKey age = mgmt.getPropertyKey("age");
		mgmt.buildIndex( "byNameComposite", Vertex.class ).addKey(name).buildCompositeIndex();
		// index consisting of multiple properties
		mgmt.buildIndex( "byNameAndAgeComposite", Vertex.class ).addKey(name).addKey(age).buildCompositeIndex();
		mgmt.commit();
		
		// wait for the index to become available
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameComposite").call();
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameAndAgeComposite").call();
		
		// create new vertex
		Vertex me = graph.addVertex("theOneAndOnly");
		me.property( "name", "me" );
		me.property( "age", 1 );
		graph.tx().commit();
		System.out.println("Created the one and only!");
		
		// re index the existing data (not required, just for demo purposes)
		mgmt = graph.openManagement();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameComposite"), SchemaAction.REINDEX ).get();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameAndAgeComposite"), SchemaAction.REINDEX ).get();
		mgmt.commit();
		
		GraphTraversalSource g = graph.traversal();
		GremlinPipeline<GraphTraversal<?, ?>, ?> pipe = new GremlinPipeline();
		
		// read our new vertex
		pipe.start( g.V().has( "name", "me" ) );	
		Vertex v = (Vertex)pipe.next();
		System.out.println();
		System.out.println( "Label: " + v.label() );
		System.out.println( "Name: " + v.property("name").value() );
		System.out.println( "Age: " + v.property("age").value() );
		System.out.println();
		
		// read different vertex
		pipe.start( g.V().has( "name", "hercules" ) );	
		Vertex herclues = (Vertex)pipe.next();
		System.out.println( "Label: " + herclues.label() );
		System.out.println( "Name: " + herclues.property("name").value() );
		System.out.println( "Age: " + herclues.property("age").value() );
		
		// print some edges
		Iterator<Edge> it = herclues.edges( Direction.OUT );
		while( it.hasNext() ) {
			Edge e = it.next();
			System.out.println( "Out: " + e.label()  + " --> " + e.inVertex().property("name").value() );
		}
		System.out.println();
		
		// close graph
		graph.close();
		// close elastic search on shutdown
		node.close();
		
		System.exit(0);
	}
 
開發者ID:maltesander,項目名稱:titan-cassandra-elasticsearch-index,代碼行數:75,代碼來源:TitanStart.java

示例5: testLargeDegreePerformance

import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public void testLargeDegreePerformance() {
    long ts = System.currentTimeMillis();

    Vertex one = graph.addVertex();
    one.property("one", "1");
    Object oneId = one.id();

    int numVertices = 10000; // 1000000;
    Object[] vids = new Object[numVertices];
    for (int i = 0; i < numVertices; i++) { // Change to 1M for perf
        Vertex many = graph.addVertex();
        many.property("many", "2");
        addEdge(graph, one, many, "toMany");
        vids[i] = many.id();

        if (i % 1000 == 0) {
            System.out.println(i + " 1000 in " + (System.currentTimeMillis() - ts));
            ts = System.currentTimeMillis();

            graph.tx().commit();
            one = graph.vertices(oneId).next();
        }
    }
    
    for (int i=0; i < numVertices; i++) {
        Vertex v = getVertex(graph, vids[i]);

        Iterator<Edge> iter = v.edges(Direction.BOTH);
        assertTrue(iter.hasNext());
        iter.next();
        assertFalse(iter.hasNext());

        v.remove();

        if (i % 1000 == 0) {
            System.out.println(i + " 1000 in " + (System.currentTimeMillis() - ts));
            
            if (i % 5000 == 0) {
                Iterator<Edge> iter2 = getVertex(graph, one.id()).edges(Direction.BOTH);
                for (int j=0; j < numVertices - i - 1; j++) {
                    assertTrue(iter2.hasNext());
                    iter2.next();
                }
                assertFalse(iter.hasNext());
            }
            
            ts = System.currentTimeMillis();

            graph.tx().commit();
        }
    }

    graph.tx().commit();
}
 
開發者ID:lambdazen,項目名稱:bitsy,代碼行數:55,代碼來源:BitsyGraphIT.java


注:本文中的org.apache.tinkerpop.gremlin.structure.Vertex.edges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。