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


Java Result.columnAs方法代码示例

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


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

示例1: createVertex

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public Vertex createVertex(long id, int weight) {
    Vertex v = null;
    try {
        beginTransaction();
        Result result = graphDb.execute("MERGE (a:NODE{INDEX:" + id + "}) RETURN a");
        Iterator<Node> n_column = result.columnAs("a");
        Node node = null;
        for (Node n : IteratorUtil.asIterable(n_column)) {
            node = n;
        }
        node.setProperty(NetworkNeo4jProperties.WEIGHT, weight);
        node.setProperty(NetworkNeo4jProperties.LEVEL, (int) 0);
        v = new Vertex(id, weight);
    } finally {
        endTransaction();
    }

    return v;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:21,代码来源:NetworkNeo4j.java

示例2: getWeightEdges

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public int getWeightEdges(long id) {

    Iterator<Integer> list;
    int weight = 0;

    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH  (a:NODE{INDEX:" + id + "})-[r:LINK]-(b) "
                + "RETURN SUM(r.WEIGHT) AS total");
        list = result.columnAs("total");
        if (list.hasNext()) {
            int value = list.next();
            weight = (int) value;
        }
    } finally {
        endTransaction();
    }

    return weight;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:22,代码来源:NetworkNeo4j.java

示例3: edgeExist

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public boolean edgeExist(long id1, long id2) {
    boolean res = false;
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + String.valueOf(id1) + "})-[r:LINK]-(b:NODE{INDEX:" + String.valueOf(id2) + "}) RETURN r LIMIT 1");
        Relationship rel_result = null;
        Iterator<Relationship> n_column = result.columnAs("r");
        for (Relationship rel : IteratorUtil.asIterable(n_column)) {
            rel_result = rel;
        }
        if (rel_result != null) {
            res = false;
        }
    } finally {
        endTransaction();
    }

    return res;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:21,代码来源:NetworkNeo4j.java

示例4: getNumVertexWithoutPartition

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public int getNumVertexWithoutPartition() {

    int num = 0;
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (n:NODE) WHERE n.PARTITION IS NULL RETURN n");
        Iterator<Integer> list = result.columnAs("n");
        num = IteratorUtil.count(list);
    } finally {
        endTransaction();
    }

    return num;//IteratorUtil.count(list);

}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:17,代码来源:NetworkNeo4j.java

示例5: getVertexFrontierWeight

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public int getVertexFrontierWeight(long id, int partition) {

    Iterator<Integer> list;
    int frontierWeight = 0;
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + id + "})-[r:LINK]-(b:NODE{PARTITION:" + partition + "}) "
                + "RETURN SUM(r.WEIGHT) AS total");
        list = result.columnAs("total");
        if (list.hasNext()) {
            int value = list.next();
            frontierWeight = (int) value;
        }
    } finally {
        endTransaction();
    }

    return frontierWeight;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:21,代码来源:NetworkNeo4j.java

示例6: getCutWeight

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public int getCutWeight() {

    Iterator<Integer> list;
    int cutWeight = 0;
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH  (a:NODE), (b:NODE), (a)-[r:LINK]->(b) "
                + "WHERE a.PARTITION <> b.PARTITION "
                + "RETURN SUM(r.WEIGHT) AS total");
        list = result.columnAs("total");
        if (list.hasNext()) {
            int value = list.next();
            cutWeight = (int) value;
        }
    } finally {
        endTransaction();
    }

    return cutWeight;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:22,代码来源:NetworkNeo4j.java

示例7: gainOfVertex

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public int gainOfVertex(Vertex v) {

    Iterator<Long> list;
    int gain = 0;
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH  (a:NODE{INDEX:1}), (a)-[r:LINK]-(b) "
                + "RETURN SUM( "
                + "CASE a.PARTITION "
                + "WHEN b.PARTITION "
                + "THEN 1 "
                + "ELSE -1 "
                + "END) AS gain");
        list = result.columnAs("gain");
        if (list.hasNext()) {
            long value = list.next();
            gain = (int) value;
        }
    } finally {
        endTransaction();
    }

    return gain;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:26,代码来源:NetworkNeo4j.java

示例8: execute

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public Graph execute(Map<String, List<String>> parameters, Integer limit)
{
    String vertexQuery = prepareGetVertexQuery(parameters, limit);
    Result result = (Result) currentStorage.executeQuery(vertexQuery);
    Iterator<Node> nodeSet = result.columnAs(VERTEX_ALIAS);
    Node node;
    if(nodeSet.hasNext())
    {
        // starting point can only be one vertex
        node = nodeSet.next();
    }
    else
        return null;
    Iterable<Relationship> relationships = node.getRelationships(Direction.INCOMING);
    Graph children = new Graph();
    for(Relationship relationship: relationships)
    {
        children.putVertex(convertNodeToVertex(relationship.getEndNode()));
    }


    return children;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:25,代码来源:GetChildren.java

示例9: prepareVertexSetFromNeo4jResult

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
protected Set<AbstractVertex> prepareVertexSetFromNeo4jResult(String query)
{
    Set<AbstractVertex> vertexSet = new HashSet<>();
    try
    {
        Result result = (Result) currentStorage.executeQuery(query);
        Iterator<Node> nodeSet = result.columnAs(VERTEX_ALIAS);
        AbstractVertex vertex;
        while(nodeSet.hasNext())
        {
            vertex = convertNodeToVertex(nodeSet.next());
            if(!vertex.isEmpty())
                vertexSet.add(vertex);
        }
    }
    catch (Exception ex)
    {
        Logger.getLogger(Neo4j.class.getName()).log(Level.SEVERE, "Vertex set querying unsuccessful!", ex);
    }

    return vertexSet;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:23,代码来源:Neo4j.java

示例10: prepareEdgeSetFromNeo4jResult

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
protected Set<AbstractEdge> prepareEdgeSetFromNeo4jResult(String query)
{
    Set<AbstractEdge> edgeSet = new HashSet<>();
    try
    {
        Result result = (Result) currentStorage.executeQuery(query);
        Iterator<Relationship> relationshipSet = result.columnAs(EDGE_ALIAS);
        AbstractEdge edge;
        while(relationshipSet.hasNext())
        {
            edge = convertRelationshipToEdge(relationshipSet.next());
            if(!edge.isEmpty())
                edgeSet.add(edge);
        }
    }
    catch (Exception ex)
    {
        Logger.getLogger(Neo4j.class.getName()).log(Level.SEVERE, "Edge set querying unsuccessful!", ex);
    }

    return edgeSet;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:23,代码来源:Neo4j.java

示例11: execute

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
@Override
public Graph execute(Map<String, List<String>> parameters, Integer limit)
{
    String vertexQuery = prepareGetVertexQuery(parameters, limit);
    Result result = (Result) currentStorage.executeQuery(vertexQuery);
    Iterator<Node> nodeSet = result.columnAs(VERTEX_ALIAS);
    Node node;
    if(nodeSet.hasNext())
    {
        // starting point can only be one vertex
        node = nodeSet.next();
    }
    else
        return null;
    Iterable<Relationship> relationships = node.getRelationships(Direction.OUTGOING);
    Graph parents = new Graph();
    for(Relationship relationship: relationships)
    {
        parents.putVertex(convertNodeToVertex(relationship.getEndNode()));
    }


    return parents;
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:25,代码来源:GetParents.java

示例12: getInnerNode

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
private Node getInnerNode(long id) {
    Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + String.valueOf(id) + "}) RETURN a LIMIT 1");
    Node node_result = null;
    Iterator<Node> n_column = result.columnAs("a");
    for (Node node : IteratorUtil.asIterable(n_column)) {
        node_result = node;
    }
    return node_result;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:10,代码来源:NetworkNeo4j.java

示例13: getInnerRelationship

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
private Relationship getInnerRelationship(long id) {
    Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK{INDEX:" + String.valueOf(id) + "}]-(b:NODE) RETURN r LIMIT 1");
    Relationship rel_result = null;
    Iterator<Relationship> n_column = result.columnAs("r");
    for (Relationship rel : IteratorUtil.asIterable(n_column)) {
        rel_result = rel;
    }
    return rel_result;
}
 
开发者ID:rafaelmss,项目名称:GraphClustering,代码行数:10,代码来源:NetworkNeo4j.java

示例14: execute

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
/**
 * Execute the query on the given database.
 * @param db the database to execute the query on.
 * @return the query result.
 */
public List<EnrichedSequenceNode> execute(GraphDatabaseService db) {
	sb.append("RETURN n");
	List<EnrichedSequenceNode> result;
	try (Transaction tx = db.beginTx()) {
		Result r = db.execute(sb.toString(), parameters);
		ResourceIterator<Node> it = r.columnAs("n");
		result = IteratorUtil.asCollection(it).stream()
			.map(e -> new Neo4jSequenceNode(db, e))
			.filter(p)
			.collect(Collectors.toList());
		tx.success();
	}
	return result;
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:20,代码来源:Neo4jQuery.java

示例15: rootIterator

import org.neo4j.graphdb.Result; //导入方法依赖的package包/类
/**
 * Retrieves a resource iterator over all roots.
 * The roots are all the nodes with no incoming edges.
 * @return	a resource iterator
 */
protected ResourceIterator<Node> rootIterator() {
	ResourceIterator<Node> roots;
	Result res = service.execute(GET_ROOT);
	roots = res.columnAs("s");
	return roots;
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:12,代码来源:Neo4jGraph.java


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