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


Java Graph类代码示例

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


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

示例1: getNode

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
@GET
@Path("/{id}")
@ApiOperation(value = "Get all properties of a node", response = Graph.class)
@Timed
@CacheControl(maxAge = 2, maxAgeUnit = TimeUnit.HOURS)
@Produces({MediaType.APPLICATION_JSON, CustomMediaTypes.APPLICATION_GRAPHSON,
    MediaType.APPLICATION_XML, CustomMediaTypes.APPLICATION_GRAPHML,
    CustomMediaTypes.APPLICATION_XGMML, CustomMediaTypes.TEXT_GML, CustomMediaTypes.TEXT_CSV,
    CustomMediaTypes.TEXT_TSV, CustomMediaTypes.IMAGE_JPEG, CustomMediaTypes.IMAGE_PNG})
public Object getNode(
    @ApiParam(value = DocumentationStrings.GRAPH_ID_DOC,
        required = true) @PathParam("id") String id,
    @ApiParam(value = DocumentationStrings.PROJECTION_DOC,
        required = false) @QueryParam("project") @DefaultValue("*") Set<String> projection,
    @ApiParam(value = DocumentationStrings.JSONP_DOC,
        required = false) @QueryParam("callback") String callback) {
  return getNeighbors(id, new IntParam("0"), new BooleanParam("false"), Optional.<String>empty(),
      null, new BooleanParam("false"), projection, callback);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:20,代码来源:GraphService.java

示例2: 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

示例3: getUser

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
public User getUser( String id ) {
	Graph graph = (Graph) connection.get();
	logger.debug("getUser: " + id );
	
	try {
		Vertex v = graph.getVertex( id );
		
		if( v == null ) {
			throw new UserNotFoundException( id );
		}

		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() 
							);
		return user;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:23,代码来源:GremlinUserDAO.java

示例4: 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

示例5: updateUser

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
public boolean updateUser( User user ) {
	Graph graph = (Graph) connection.get();
	logger.debug("updateUser: " + user.getId() );
	
	try{
		Vertex v = graph.getVertex( user.getId() );
		
		if( v== null ) throw new UserNotFoundException( user.getEmail() );
		
		if( user.getEmail() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL, user.getEmail() );
		if( user.getFirstname() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME, user.getFirstname() );
		if( user.getLastname() != null )
			v.setProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME, user.getLastname() );
		
		return true;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:23,代码来源:GremlinUserDAO.java

示例6: deleteUser

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
public boolean deleteUser( String id ) {
	Graph graph = (Graph) connection.get();
	logger.debug("deleteUser: " + id );
	
	try {
		Vertex v = graph.getVertex( id );
		
		if( v== null ) throw new UserNotFoundException( id );
		
		v.remove();
		return true;
	}
	finally {
		graph.shutdown();
	}
}
 
开发者ID:maltesander,项目名称:rest-jersey2-json-jwt-authentication,代码行数:17,代码来源:GremlinUserDAO.java

示例7: 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

示例8: checkIndexUniqueness

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
@Override
public <T extends MeshElement> T checkIndexUniqueness(String indexName, Class<T> classOfT, Object key) {
	FramedGraph graph = Tx.getActive().getGraph();
	Graph baseGraph = ((DelegatingFramedOrientGraph) graph).getBaseGraph();
	OrientBaseGraph orientBaseGraph = ((OrientBaseGraph) baseGraph);

	OrientVertexType vertexType = orientBaseGraph.getVertexType(classOfT.getSimpleName());
	if (vertexType != null) {
		OIndex<?> index = vertexType.getClassIndex(indexName);
		if (index != null) {
			Object recordId = index.get(key);
			if (recordId != null) {
				return (T) graph.getFramedVertexExplicit(classOfT, recordId);
			}
		}
	}
	return null;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:19,代码来源:OrientDBDatabase.java

示例9: testVertexEdgesWithNonVisibleVertexOnOtherEnd

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
public void testVertexEdgesWithNonVisibleVertexOnOtherEnd() {
    Graph graph = graphTest.generateGraph();

    if (!(graph instanceof VertexiumBlueprintsGraph)) {
        throw new RuntimeException("Invalid graph");
    }
    org.vertexium.Graph vertexiumGraph = ((VertexiumBlueprintsGraph) graph).getGraph();

    Authorizations aAuthorizations = vertexiumGraph.createAuthorizations("a");
    org.vertexium.Vertex v1 = vertexiumGraph.addVertex("v1", new Visibility(""), aAuthorizations);
    org.vertexium.Vertex v2 = vertexiumGraph.addVertex("v2", new Visibility("a"), aAuthorizations);
    org.vertexium.Vertex v3 = vertexiumGraph.addVertex("v3", new Visibility(""), aAuthorizations);
    vertexiumGraph.addEdge("e1to2", v1, v2, "label", new Visibility(""), aAuthorizations);
    vertexiumGraph.addEdge("e1to3", v1, v3, "label", new Visibility(""), aAuthorizations);
    vertexiumGraph.flush();

    Vertex blueV1 = graph.getVertex("v1");
    assertEquals(1, count(blueV1.getEdges(Direction.BOTH, "label")));
    assertEquals(1, count(blueV1.getVertices(Direction.BOTH, "label")));
    assertEquals(1, count((Iterable) blueV1.query().direction(Direction.BOTH).vertexIds()));

    graph.shutdown();
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:24,代码来源:VertexiumBlueprintsVertexTestBase.java

示例10: exportFunction

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
private void exportFunction(Vertex vertex) throws IOException
{

	executor.execute(() -> {
		Graph graph = orientConnector.getNoTxGraphInstance();
		try
		{
			Vertex functionRoot = graph.getVertex(vertex);
			Graph subgraph = new TinkerGraph();
			copyFunctionNodes(subgraph, functionRoot);
			copyFunctionEdges(subgraph, functionRoot);
			subgraph.shutdown();
			Path out = Paths.get(outputDirectory.toString(), "func" +
					functionRoot.getId().toString().split(":")[1] +
					"." + format);
			writeGraph(subgraph, out);
		} catch (IOException e)
		{
			e.printStackTrace();
		} finally
		{
			graph.shutdown();
		}
	});

}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:27,代码来源:FunctionExportPlugin.java

示例11: writeGraph

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
private void writeGraph(Graph graph, Path path) throws IOException
{
	OutputStream out = Files.newOutputStream(path);
	switch (format)
	{
		case "graphml":
			GraphMLWriter.outputGraph(graph, out);
			break;
		case "gml":
			GMLWriter.outputGraph(graph, out);
			break;
		case "dot":
			DotWriter.outputGraph(graph, out);
			break;
		default:
			GraphMLWriter.outputGraph(graph, out);
			break;
	}
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:20,代码来源:FunctionExportPlugin.java

示例12: copyEdge

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
private static void copyEdge(Graph graph, Edge edge)
{
	Object id = edge.getId();
	if (graph.getEdge(id) != null)
	{
		return;
	}
	Vertex src = graph.getVertex(edge.getVertex(Direction.OUT).getId());
	Vertex dst = graph.getVertex(edge.getVertex(Direction.IN).getId());
	if (src != null && dst != null)
	{
		Edge e = GraphHelper.addEdge(graph, id, src, dst, edge.getLabel());
		if (e != null)
		{
			ElementHelper.copyProperties(edge, e);
		}
	}
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:19,代码来源:FunctionExportPlugin.java

示例13: injectEdges

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
/**
 * Helper method to iterate over the outgoing edges in graml and them to the graph. As the destination vertex must
 * be referenced for this operation, a lookup will be performed to find an existing target vertex matching that in
 * graml or a new vertex will be created if it does not exist yet.
 *
 * @param g
 * @param srcVertexName
 * @param srcVertex
 * @param edgeName
 * @param target
 */
private void injectEdges(final Graph g, final String srcVertexName, final Vertex srcVertex, final String edgeName,
        final Object target) {
    if (target instanceof List) {
        @SuppressWarnings("unchecked")
        List<String> targetNames = (List<String>) target;
        targetNames.forEach(targetName -> injectEdges(g, srcVertexName, srcVertex, edgeName, targetName));
    } else if (target instanceof Map) {
        throw new GramlException(format("Source vertex \"%s\" may not use an arbitrary map as an edge target.",
                srcVertexName));
    } else {
        Vertex targetVertex = findOrCreateVertex(g, (String) target);
        // TODO: Enable custom edge classes

        Edge edge = srcVertex.addEdge(edgeName, targetVertex);
        edgeProps.updateEdgeProperties(edgeName, edge);
    }
}
 
开发者ID:segfly-oss,项目名称:graml,代码行数:29,代码来源:GraphSectionImpl.java

示例14: findOrCreateVertex

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
/**
 * Helper method to find an existing vertex. First the local cache is checked, then the in-memory (uncommitted)
 * graph object, the finally the database.
 *
 * @param g
 * @param vertexName
 * @return
 */
private Vertex findOrCreateVertex(final Graph g, final String vertexName) {
    String resolvedVertexName = classmap.resolveVertex(vertexName);
    boolean usingClasses = !vertexName.equals(resolvedVertexName);

    Vertex vertex = (Vertex) vertexCache.get(vertexName);
    if (vertex == null) {
        // FIXME Properly query for vertices in DB if getByID misses
        if (!usingClasses) {
            vertex = g.getVertex(resolvedVertexName);
        }

        if (vertex == null) {
            vertex = g.addVertex(resolvedVertexName);
            if (usingClasses) {
                vertex.setProperty(GraphSectionImpl.ELEMENT_NAME_PROPERTY, vertexName);
            }
        }
    }

    vertexProps.updateVertexProperties(vertexName, vertex);
    vertexCache.put(vertexName, vertex);
    return vertex;
}
 
开发者ID:segfly-oss,项目名称:graml,代码行数:32,代码来源:GraphSectionImpl.java

示例15: getEvidenceGraph

import com.tinkerpop.blueprints.Graph; //导入依赖的package包/类
String getEvidenceGraph(Graph graph, Optional<String> metaSourceQuery) {
  TinkerGraphUtil tgu = new TinkerGraphUtil(graph, curieUtil);
  tgu.project(singleton("label"));
  BbopGraph bbopGraph = bbopUtil.convertGraph(tgu.getGraph());
  if (metaSourceQuery.isPresent()) {
    Map<String, Object> currentMeta = bbopGraph.getMeta();
    currentMeta.put("query", "monarch:cypher/" + metaSourceQuery.get());
  }
  StringWriter writer = new StringWriter();
  try {
    MAPPER.writeValue(writer, bbopGraph);
  } catch (IOException e) {
    e.printStackTrace();
  }
  return writer.toString();
}
 
开发者ID:SciGraph,项目名称:golr-loader,代码行数:17,代码来源:EvidenceProcessor.java


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