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


Java GlobalGraphOperations类代码示例

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


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

示例1: executeForestFireModel

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
private GraphStructure executeForestFireModel(GraphStructure graph, ForestFireModelParameters parameters,
		boolean directed) {
	GraphDatabaseService database = ValidationGraphLoader.loadValidationGraphToDatabase(graph);
	new ForestFireModelComputation(database, parameters, directed).run();

	Map<Long, Set<Long>> edgeLists = new HashMap<>();
	try (Transaction ignored = database.beginTx()) {
		for (Node node : GlobalGraphOperations.at(database).getAllNodes()) {
			edgeLists.put((long)node.getProperty(ID_PROPERTY), new HashSet<Long>());
		}
		for (Relationship relationship : GlobalGraphOperations.at(database).getAllRelationships()) {
			if (relationship.isType(EDGE)) {
				edgeLists.get(relationship.getStartNode().getProperty(ID_PROPERTY))
						.add((long)relationship.getEndNode().getProperty(ID_PROPERTY));
			}
		}
	}
	database.shutdown();
	return new GraphStructure(edgeLists);
}
 
开发者ID:atlarge-research,项目名称:graphalytics-platforms-neo4j,代码行数:21,代码来源:ForestFireModelComputationTest.java

示例2: executeBreadthFirstSearch

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
private BreadthFirstSearchOutput executeBreadthFirstSearch(GraphStructure graph,
		BreadthFirstSearchParameters parameters, boolean directed) {
	GraphDatabaseService database = ValidationGraphLoader.loadValidationGraphToDatabase(graph);
	new BreadthFirstSearchComputation(database, parameters.getSourceVertex(), directed).run();

	Map<Long, Long> output = new HashMap<>();
	try (Transaction ignored = database.beginTx()) {
		for (Node node : GlobalGraphOperations.at(database).getAllNodes()) {
			if (node.hasProperty(DISTANCE)) {
				output.put((long)node.getProperty(ID_PROPERTY), (long)node.getProperty(DISTANCE));
			} else {
				output.put((long)node.getProperty(ID_PROPERTY), Long.MAX_VALUE);
			}
		}
	}
	database.shutdown();
	return new BreadthFirstSearchOutput(output);
}
 
开发者ID:atlarge-research,项目名称:graphalytics-platforms-neo4j,代码行数:19,代码来源:BreadthFirstSearchComputationTest.java

示例3: allNodes

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@Override
public IGraphIterable<IGraphNode> allNodes(String label) {

	if (graph != null) {

		GlobalGraphOperations g = GlobalGraphOperations.at(graph);

		return (label == null) ? (new Neo4JIterable<IGraphNode>(
				g.getAllNodes(), this)) : (new Neo4JIterable<IGraphNode>(
				g.getAllNodesWithLabel(Neo4JBatchUtil.createLabel(label)),
				this));

	} else {
		LOGGER.warn("allNodes called in a batch isert mode, please exit batch insert first, returning null");
		return null;
	}
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:18,代码来源:Neo4JDatabase.java

示例4: warmUp

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@GET
@Path("/warmup")
public Response warmUp(@Context GraphDatabaseService db) throws IOException {
    try ( Transaction tx = db.beginTx() )
    {

        for (Node node : GlobalGraphOperations.at(db).getAllNodes()) {
            node.getPropertyKeys();
        }

        for ( Relationship relationship : GlobalGraphOperations.at(db).getAllRelationships()){
            relationship.getPropertyKeys();
            relationship.getNodes();
        }
    }

    Map<String, String> results = new HashMap<String,String>(){{
        put("response","Warmed up and ready to go!");
    }};

    return Response.ok().entity(objectMapper.writeValueAsString(results)).build();
}
 
开发者ID:maxdemarzi,项目名称:neo_warmup,代码行数:23,代码来源:Service.java

示例5: analyzePartitions

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
public void analyzePartitions() {
    // Query the nodes by label, which each set becomes a partition for analysis
    Transaction tx = graphDatabaseService.beginTx();

    Iterator<Node> partitions = GlobalGraphOperations.at(graphDatabaseService)
            .getAllNodesWithLabel(DynamicLabel.label(label))
            .iterator();

    // For each partition, query the target relationships between the partition
    partitions.forEachRemaining(partition -> {
        PartitionDescription partitionDescription = new PartitionDescription(partition.getId(), label);
        partitionDescription.setGroupRelationship(groupRelationship);
        partitionDescription.setTargetRelationship(targetRelationship);
        try {
            Path pt = Writer.exportPartitionToHDFSParallel(graphDatabaseService, partition, partitionDescription);
            if(pt != null)
                Writer.dispatchPartitionedJob(graphDatabaseService, type, partitionDescription, pt);
        } catch (IOException | URISyntaxException e) {
            e.printStackTrace();
        }
    });

    tx.success();
    tx.close();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mazerunner,代码行数:26,代码来源:PartitionedAnalysis.java

示例6: getFeatureIndexList

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
private static List<Integer> getFeatureIndexList(GraphDatabaseService db) {
    Transaction tx = db.beginTx();
    // Get classes using Java API
    final List<Node> patterns = new ArrayList<>();
    GlobalGraphOperations.at(db)
            .getAllNodesWithLabel(DynamicLabel.label("Pattern"))
            .forEach(a -> patterns.add(a));

    Collections.sort(patterns, (a, b) -> ((Integer)b.getProperty("threshold")).compareTo(((Integer)a.getProperty("threshold"))));

    List<Integer> patternIds = patterns.stream()
            .filter(a -> getFeatureMatchDistribution(db, a.getId()) > CONFIDENCE_INTERVAL)
            .map(a -> ((Long)a.getId()).intValue()).collect(Collectors.toList());

    tx.success();
    tx.close();

    return patternIds;
}
 
开发者ID:Graphify,项目名称:graphify,代码行数:20,代码来源:VectorUtil.java

示例7: getAllNodes

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
public static List<String> getAllNodes(final GraphDatabaseService graphDb,
                                       final String labelName) {

    List<String> nodeIds = new ArrayList<>();
    Label label = DynamicLabel.label(labelName);
    ResourceIterable<Node> nodes;

    try (Transaction tx = graphDb.beginTx()) {
        nodes = GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(label);

        for (Node node : nodes) {
            try {
                nodeIds.add(node.getProperty("node_id").toString());
            } catch (Exception e) {
                LOGGER.warn("Can't find a given node... skipping");
            }
        }

        tx.success();
    }

    return nodeIds;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:25,代码来源:NeoHelpers.java

示例8: ExportDot

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
private String ExportDot(Iterable<Node> nodes)
{
	OutputStream out = new ByteArrayOutputStream();

	GraphvizWriter writer = new GraphvizWriter();

	Iterable<RelationshipType> types = GlobalGraphOperations.at(graph_db).getAllRelationshipTypes();

	try
	{
		writer.emit(out, Walker.crosscut(nodes
			, Iterables.toArray(types, RelationshipType.class)));
	}
	catch(IOException e)
	{
		throw new ExceptionModelFail
			("Traverse during export to .dot file failed: "
				+ e.getMessage());
	}

	return out.toString();
}
 
开发者ID:srcc-msu,项目名称:octotron_core,代码行数:23,代码来源:Neo4jGraph.java

示例9: primeRegistryByGraph

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
protected void primeRegistryByGraph(GraphDatabaseService graph){
	LayoutDataRegistry registry = LayoutDataRegistry.getInstance();

	for(Node n : GlobalGraphOperations.at(graph).getAllNodes()){
		ForceAtlas2LayoutData nLayout = registry.setLayoutData(n, new ForceAtlas2LayoutData());

		nLayout.old_dx = (Double)n.getProperty(PREFIX_odx, 0.0); 
		nLayout.old_dy = (Double)n.getProperty(PREFIX_ody, 0.0);
		nLayout.dx = (Double)n.getProperty(PREFIX_dx, 0.0);
		nLayout.dy = (Double)n.getProperty(PREFIX_dy, 0.0);
		nLayout.mass = (Double)n.getProperty(PREFIX_mass, 1+n.getDegree());
		nLayout.size = (Double)n.getProperty(PREFIX_size, 0.0);

		nLayout.x = (Double)n.getProperty(PREFIX_X, 0.0);
		nLayout.y = (Double)n.getProperty(PREFIX_Y, 0.0);
	}
}
 
开发者ID:gsummer,项目名称:neoLayouts,代码行数:18,代码来源:ForceAtlas2LayoutExtension.java

示例10: getNodeCount

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@Override
public int getNodeCount()
{
    int nodeCount = 0;
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            nodeCount = IteratorUtil.count(GlobalGraphOperations.at(neo4jGraph).getAllNodes());
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get node count", e);
        }
    }

    return nodeCount;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:21,代码来源:Neo4jGraphDatabase.java

示例11: initCommunityProperty

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@Override
public void initCommunityProperty()
{
    int communityCounter = 0;

    // maybe commit changes every 1000 transactions?
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            for (Node n : GlobalGraphOperations.at(neo4jGraph).getAllNodes())
            {
                n.setProperty(NODE_COMMUNITY, communityCounter);
                n.setProperty(COMMUNITY, communityCounter);
                communityCounter++;
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to initialize community property", e);
        }
    }
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:26,代码来源:Neo4jGraphDatabase.java

示例12: getGraphWeightSum

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@Override
public double getGraphWeightSum()
{
    int edgeCount = 0;

    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            edgeCount = IteratorUtil.count(GlobalGraphOperations.at(neo4jGraph).getAllRelationships());
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get graph weight sum", e);
        }
    }

    return (double) edgeCount;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:22,代码来源:Neo4jGraphDatabase.java

示例13: getGraph

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
public static Graph<Node,Relationship> getGraph(GlobalGraphOperations o) {
    Iterator<Node> nit = o.getAllNodes().iterator();
    Iterator<Relationship> rit = o.getAllRelationships().iterator();

    // make a graph
    Graph<Node,Relationship> graph = new DirectedSparseGraph<Node, Relationship>();
    
    while(nit.hasNext()){
        Node n = nit.next();
        graph.addVertex(n);
    }
    
    while(rit.hasNext()){
        Relationship r = rit.next();
        graph.addEdge(r, r.getStartNode(), r.getEndNode());
    }
    return graph;
}
 
开发者ID:datagr4m,项目名称:org.datagr4m,代码行数:19,代码来源:Neo4jNodeTypeAnalysis.java

示例14: getStartIdentifier

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
@Override
public InternalIdentifier getStartIdentifier() {
	log.trace("Fetching (random) root Identifier from the database");
	InternalIdentifier result = null;
	try (Transaction tx = beginTx()) {
		Iterator<Node> allNodes = GlobalGraphOperations.at(mConnection.getConnection()).getAllNodesWithLabel(Neo4JTypeLabels.IDENTIFIER).iterator();
		if(allNodes.hasNext()) {
			result =  new Neo4JIdentifier(allNodes.next(), this);
		}
		else {
			log.warn("Seems there is no Identifier in the database that could be used as a root");
			result =  null;
		}
		tx.success();
	}
	return result;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:18,代码来源:Neo4JRepository.java

示例15: incrementCounter

import org.neo4j.tooling.GlobalGraphOperations; //导入依赖的package包/类
public void incrementCounter(long timestamp) {
	try (Transaction tx = mConnection.getConnection().beginTx()) {
		Node changeNode = null;
		Iterator<Node> change = GlobalGraphOperations.at(mConnection.getConnection()).getAllNodesWithLabel(Neo4JTypeLabels.CHANGE).iterator();
		if (!change.hasNext()) {
			changeNode = mConnection.getConnection().createNode();
			changeNode.addLabel(Neo4JTypeLabels.CHANGE);
		} else {
			changeNode = change.next();
		}
		if (!changeNode.hasProperty(timestamp + "")) {
			changeNode.setProperty(timestamp + "",
					(long) 1);
		} else {
			long count = (long) changeNode.getProperty(timestamp+"");
			count++;
			changeNode.setProperty(timestamp+"", count);

		}
		tx.success();
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:23,代码来源:Neo4JTimestampManager.java


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