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


Java Graph.getVertices方法代码示例

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


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

示例1: getUserIdByEmail

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public String getUserIdByEmail( String email ) {
	Graph graph = (Graph) connection.get();
	logger.debug("getUserIdByEmail: " + email );
	
	try {
	
		Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.USER_PROPERTY_EMAIL, email );
		Iterator<Vertex> it = iterable.iterator();
		
		if( it.hasNext() ) {
			return it.next().getId().toString();
		}
		else {
			throw new UserNotFoundException( email );
		}
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:21,代码来源:GremlinUserDAO.java

示例2: getAllUsers

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public List<User> getAllUsers() {
	List<User> users = new ArrayList<User>();
	Graph graph = (Graph) connection.get();
	logger.debug("getAllUsers" );
	
	try {
		Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.UNIVERSAL_PROPERTY_TYPE, GremlinDAOSpec.USER_CLASS );
		Iterator<Vertex> it = iterable.iterator();
		
		while( it.hasNext() ) {
			Vertex v = it.next();
			User user = new User( v.getId().toString(),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL ),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME ).toString(),
								  v.getProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME ).toString() 
								);
			users.add(user);
		}

		return users;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:27,代码来源:GremlinUserDAO.java

示例3: testGetGraphRelsOnly

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testGetGraphRelsOnly() {
	LoadingSheetData rels
			= LoadingSheetData.relsheet( "Human Being", "Car", "Purchased" );
	rels.addProperties( Arrays.asList( "Price", "Date" ) );
	ValueFactory vf = new ValueFactoryImpl();
	Map<String, Value> props = new HashMap<>();
	props.put( "Price", vf.createLiteral( "3000 USD" ) );
	rels.add( "Yuri", "Yugo", props );
	rels.add( "Yuri", "Pinto" );

	Graph g = GsonWriter.getGraph( data );
	int vsize = 0;
	int esize = 0;
	for ( Vertex v : g.getVertices() ) {
		vsize++;
	}
	for ( Edge e : g.getEdges() ) {
		esize++;
	}

	assertEquals( 3, vsize );
	assertEquals( 2, esize );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:GsonWriterTest.java

示例4: applyGraphToMeta

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public static void applyGraphToMeta( Graph g ) {

    if ( g != null ) {

      for ( Vertex v : g.getVertices() ) {
        GUIPositionInterface meta = v.getProperty( GraphUtils.PROPERTY_REF );
        Point originaLocation = meta.getLocation();
        int newX = v.getProperty( GraphUtils.PROPERTY_X );
        int newY = v.getProperty( GraphUtils.PROPERTY_Y );

        boolean changed = ( originaLocation.x != newX || originaLocation.y != newY );
        if ( changed ) {
          meta.setLocation( newX, newY );
          ( (StepMeta) meta ).setChanged( true );
        }
      }
    }
    getActiveGraph().redraw();
  }
 
开发者ID:mattyb149,项目名称:pdi-layout,代码行数:20,代码来源:LayoutUtils.java

示例5: writeTo

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
    MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException {
  try (Writer writer = new OutputStreamWriter(out);
      CSVPrinter printer = getCsvPrinter(writer)) {
    List<String> header = newArrayList("id", "label", "categories");
    printer.printRecord(header);
    List<String> vals = new ArrayList<>();
    for (Vertex vertex: data.getVertices()) {
      vals.clear();
      vals.add(getCurieOrIri(vertex));
      String label = getFirst(TinkerGraphUtil.getProperties(vertex, NodeProperties.LABEL, String.class), null);
      vals.add(label);
      vals.add(TinkerGraphUtil.getProperties(vertex, Concept.CATEGORY, String.class).toString());
      printer.printRecord(vals);
    }
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:19,代码来源:DelimitedWriter.java

示例6: testGetGraph1

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testGetGraph1() {
	Graph g = GsonWriter.getGraph( data );
	int vsize = 0;
	int esize = 0;
	for ( Vertex v : g.getVertices() ) {
		vsize++;
	}
	for ( Edge e : g.getEdges() ) {
		esize++;
	}

	assertEquals( 3, vsize );
	assertEquals( 2, esize );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:16,代码来源:GsonWriterTest.java

示例7: getEvidenceObject

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
List<Closure> getEvidenceObject(Graph graph, Set<Long> ignoredNodes) {
  List<Closure> closures = new ArrayList<>();
  for (Vertex vertex : graph.getVertices()) {
    if (ignoredNodes.contains(Long.parseLong((String) vertex.getId()))) {
      continue;
    }
    Node node = graphDb.getNodeById(Long.parseLong((String) vertex.getId()));
    closures.add(closureUtil.getClosure(node, SolrDocUtil.DEFAULT_CLOSURE_TYPES));
  }
  return closures;
}
 
开发者ID:SciGraph,项目名称:golr-loader,代码行数:12,代码来源:EvidenceProcessor.java

示例8: applyLayout

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public void applyLayout( Graph graph, int canvasWidth, int canvasHeight ) {

  if ( graph != null ) {
    final int MARGIN = 5;

    // Pick (X,Y) at random and set each step to those values
    // TODO prevent overlap?
    for ( Vertex v : graph.getVertices() ) {
      v.setProperty( GraphUtils.PROPERTY_X, ThreadLocalRandom.current().nextInt( MARGIN, canvasWidth - MARGIN ) );
      v.setProperty( GraphUtils.PROPERTY_Y, ThreadLocalRandom.current().nextInt( MARGIN, canvasHeight - MARGIN ) );
    }
  }
}
 
开发者ID:mattyb149,项目名称:pdi-layout,代码行数:15,代码来源:RandomLayout.java

示例9: addCuries

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
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());
    }
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:10,代码来源:CurieAdder.java

示例10: addGraph

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public void addGraph(Graph addition) {
  for (Vertex vertex : addition.getVertices()) {
    addElement(vertex);
  }
  for (Edge edge : addition.getEdges()) {
    addElement(edge);
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:9,代码来源:TinkerGraphUtil.java

示例11: getCandidateIterable

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public Iterable<Set<Vertex>> getCandidateIterable(Graph g, int numTriangles) {
    List<Vertex> vertices = new ArrayList<>();

    for(Vertex v : g.getVertices()) {
        vertices.add(v);
    }

    Collections.sort(vertices, (Vertex l, Vertex r) -> {
        Integer lDeficit = l.getProperty("degreeDeficit");
        Integer rDeficit = r.getProperty("degreeDeficit");
        return rDeficit.compareTo(lDeficit);
    });

    int trianglesCreated = 0;

    List<Set<Vertex>> edgeCandidates = new ArrayList<>();
    SetMultimap<Integer, Integer> edgesSoFar = HashMultimap.create();

    //Iterate the sorted vertices
    for(int i = 0; i<vertices.size(); i++){
        int degreeDeficit = vertices.get(i).getProperty("degreeDeficit");
        int stepCount = degreeDeficit;

        for(int k = 1; k<=stepCount; k++){
            if(i+k < vertices.size()) {
                int potentialTriangles = Sets.intersection(edgesSoFar.get(i), edgesSoFar.get(i + k)).size();
                int kDeficit = vertices.get(i + k).getProperty("degreeDeficit");

                if (kDeficit > 0 && (trianglesCreated + potentialTriangles <= numTriangles)) {
                    ImmutableSet<Vertex> potentialEdge = ImmutableSet.of(vertices.get(i), vertices.get(i + k));
                    edgeCandidates.add(potentialEdge);
                    edgesSoFar.put(i + k, i);
                    vertices.get(i + k).setProperty("degreeDeficit", kDeficit - 1);
                    vertices.get(i).setProperty("degreeDeficit", degreeDeficit - 1);
                } else stepCount++;
            } else if(unfinished != null) {
                //This is bad :'( . Time constraints - sorry
                unfinished.put("unfinished", true, vertices.get(i));
                vertices.get(i).setProperty("unfinished", true);
            }
        }
        edgesSoFar.removeAll(i);
    }
    return edgeCandidates;
}
 
开发者ID:hugofirth,项目名称:simple-graph-generator,代码行数:47,代码来源:DegreeFirstSelectionStrategy.java

示例12: printDeficits

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
private void printDeficits(Graph g) {
    for (Vertex v : g.getVertices()) {
        System.out.print((int)v.getProperty("degreeDeficit") + " ");
    }
    System.out.println();
}
 
开发者ID:hugofirth,项目名称:simple-graph-generator,代码行数:7,代码来源:SimpleGenerator.java

示例13: mergeVertexes

import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
private void mergeVertexes(Graph graph1, Graph graph2) {
    for (Vertex vertex2 : graph2.getVertices()) {
        mergeVertex(graph1, vertex2);
    }
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:6,代码来源:GrahmlMerge.java


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