Java 类org.neo4j.graphdb.Result 实例源码

项目:flight-management-system-java    文件:AfficherAvions.java   
public void loadTableBD(int num) {
    Result res = db.execute("MATCH (n:`Avion`{numero:"+num+"}) RETURN n.numero, n.type, n.capacite");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Numero", "Type", "Capacite"};
    String test[] = {"n.numero", "n.type", "n.capacite"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:kowalski    文件:GraphDatabaseOperations.java   
public void mergeArtifact(org.eclipse.aether.artifact.Artifact artifactModel) {
    this.artifactCache.getOrPut(artifactModel, () -> {
        String cypherQuery = "MERGE (artifact:ARTIFACT {groupId: {groupId}, artifactId: {artifactId}, version: {version}, extension: {extension}, hash: {hash}%s}) RETURN artifact";
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("groupId", artifactModel.getGroupId());
        parameters.put("artifactId", artifactModel.getArtifactId());
        parameters.put("version", artifactModel.getVersion());
        parameters.put("extension", artifactModel.getExtension());
        if (!artifactModel.getClassifier().isEmpty()) {
            cypherQuery = String.format(cypherQuery, ", classifier: {classifier}%s");
            parameters.put("classifier", artifactModel.getClassifier());
        }
        parameters.put("hash", this.hash(parameters.values().toArray(new String[0])));
        cypherQuery = String.format(cypherQuery, "");
        try (Result result = this.graphDatabaseService.execute(cypherQuery, parameters)) {
            return result.<Node>columnAs("artifact").next();
        }
    });
}
项目:flight-management-system-java    文件:AfficherDepart.java   
public void loadTableBD() {
    Result res = db.execute("MATCH (a:Avion)-[r:Affecter]->(d:Depart)<-[c:Constituer]-(v:Vol) RETURN d.numero, d.date, v.villeDep, v.villeArr,  a.type, a.capacite, v.numero, v.heureDep, v.heureArr");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Numero", "Date","Depart", "Arriveé", "Type", "Capacite", "NumVol", "Heure De Depart", "Heure d'arrive"};
    String test[] = {"d.numero", "d.date","v.villeDep", "v.villeArr", "a.type", "a.capacite", "v.numero", "v.heureDep", "v.heureArr"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:AfficherEmployees.java   
public void loadTableBD() {
    Result res = db.execute("MATCH (n:`Personnel`) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone, n.type");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Cin", "Passeport", "Nom", " Adresse", "Telephone", "Type"};
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone", "n.type"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:AfficherEmployees.java   
public void loadTableBD(int cin) {
    Result res = db.execute("MATCH (n:`Personnel`{cin:"+cin+"}) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone, n.type");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Cin", "Passport", "Nom", " Adresse", "Telephone", "Type"};
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone", "n.type"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:ModifierEmp.java   
public void loadDb(int pos, String type) {
    post= pos;
    this.type = type;
    Result res = db.execute("MATCH (n:Personnel {cin:"+pos+"}) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone");
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone"};
    Map<String, Object> obj = new LinkedHashMap();
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
    }
    res.close();
    cin.setText(obj.get("n.cin").toString());
    passeport.setText(obj.get("n.numPassport").toString());
    nom.setText(obj.get("n.nom").toString());
    tel.setText(obj.get("n.telephone").toString());
    adresse.setText(obj.get("n.adresse").toString());

}
项目:flight-management-system-java    文件:ModifierVol.java   
public void loadDb(int pos) {
    post= pos;
    Result res = db.execute("MATCH (n:Vol {numero:"+pos+"}) RETURN n.numero, n.villeDep, n.villeArr, n.heureDep, n.heureArr, n.distance, n.frequence");
    String test[] = {"n.numero", "n.villeDep", "n.villeArr", "n.heureDep", "n.heureArr", "n.distance", "n.frequence"};
    Map<String, Object> obj = new LinkedHashMap();
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
    }
    res.close();
    villeDepart.setText(obj.get("n.villeDep").toString());
    villeArrive.setText(obj.get("n.villeArr").toString());
    heureDepart.setText(obj.get("n.heureDep").toString());
    heureArrive.setText(obj.get("n.heureArr").toString());
    distance.setText(obj.get("n.distance").toString());
    frequence.setText(obj.get("n.frequence").toString());

}
项目:flight-management-system-java    文件:AfficherPassagers.java   
public void loadTableBD() {
    Result res = db.execute("MATCH (n:`Passager`) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Cin", "Passeport", "Nom", " Adresse", "Telephone"};
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:AfficherPassagers.java   
public void loadTableBD(int cin) {
    Result res = db.execute("MATCH (n:`Passager`{cin:"+cin+"}) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Cin", "Passport", "Nom", " Adresse", "Telephone"};
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:AfficherVols.java   
public void loadTableBD() {
    Result res = db.execute("MATCH (n:`Vol`) RETURN n.numero, n.villeDep, n.villeArr, n.heureDep, n.heureArr, n.distance, n.frequence ORDER BY n.numero");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"n.numero", "Depart", "Arrivee", "Heure Depart", "Heure Arrivee", "Distance", "Frequence"};
    String test[] = {"n.numero", "n.villeDep", "n.villeArr", "n.heureDep", "n.heureArr", "n.distance", "n.frequence"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:AfficherVols.java   
public void loadTableBD(int num) {
    Result res = db.execute("MATCH (n:Vol {numero:"+num+"}) RETURN n.numero, n.villeDep, n.villeArr, n.heureDep, n.heureArr, n.distance, n.frequence ORDER BY n.numero");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Numero", "Depart", "Arrivee", "Heure Depart", "Heure Arrivee", "Distance", "Frequence"};
    String test[] = {"n.numero", "n.villeDep", "n.villeArr", "n.heureDep", "n.heureArr", "n.distance", "n.frequence"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:MainWindow.java   
public void loadTableBD(String dateAuj) {
    Result res = db.execute("MATCH (a:Avion)-[r:Affecter]->(d:Depart)<-[c:Constituer]-(v:Vol) WHERE d.date='"+dateAuj+"' RETURN d.numero, d.date, v.villeDep, v.villeArr,  a.type, a.capacite, v.numero, v.heureDep, v.heureArr");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Numero", "Date","Depart", "Arriveé", "Type", "Capacite", "NumVol", "Heure De Depart", "Heure d'arrive"};
    String test[] = {"d.numero", "d.date","v.villeDep", "v.villeArr", "a.type", "a.capacite", "v.numero", "v.heureDep", "v.heureArr"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:Depart.java   
public void insertBd() {
    Result res;
    try (Transaction tx = db.beginTx()) {
        Node depart = db.createNode(Main.Tables.Depart);
        depart.setProperty("numero",numero);
        depart.setProperty("date",date);
        res = db.execute("MATCH (a:Avion), (d:Depart) WHERE a.numero="+avion+" AND d.numero="+numero+" CREATE (a)-[:Affecter]->(d)");
        res = db.execute("MATCH (v:Vol), (d:Depart) WHERE v.numero="+vol+" AND d.numero="+numero+" CREATE (v)-[:Constituer]->(d)");
        for (int i=0; i<passagers.size(); i++) {

            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+passagers.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        for (int i=0; i<personnels.size(); i++) {
            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+personnels.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        tx.success();
    }
     //res = db.execute("MATCH (d:Depart{date:'"+date+"'}), (p:Passager{cin:'"+passagers.get(0)+"'}) CREATE (p)-[r:Enregistrer]->(d)");
}
项目:flight-management-system-java    文件:ModifierPass.java   
public void loadDb(int pos) {
    post= pos;
    Result res = db.execute("MATCH (n:Passager {cin:"+pos+"}) RETURN n.cin, n.numPassport, n.nom, n.adresse, n.telephone");
    String test[] = {"n.cin", "n.numPassport", "n.nom", "n.adresse", "n.telephone"};
    Map<String, Object> obj = new LinkedHashMap();
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
    }
    res.close();
    cin.setText(obj.get("n.cin").toString());
    passeport.setText(obj.get("n.numPassport").toString());
    nom.setText(obj.get("n.nom").toString());
    tel.setText(obj.get("n.telephone").toString());
    adresse.setText(obj.get("n.adresse").toString());

}
项目:flight-management-system-java    文件:AfficherAvions.java   
public void loadTableBD() {
    Result res = db.execute("MATCH (n:`Avion`) RETURN n.numero, n.type, n.capacite");
    DefaultTableModel dtm = new DefaultTableModel(0,0);
    String header[] = {"Numero", "Type", "Capacite"};
    String test[] = {"n.numero", "n.type", "n.capacite"};
    dtm.setColumnIdentifiers(header);
    jTable1.setModel(dtm);
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        Map<String, Object> obj = new LinkedHashMap();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }

        dtm.addRow(obj.values().toArray());
}
}
项目:flight-management-system-java    文件:ModifierAvion.java   
public void loadDb(int pos) {
    post= pos;
    Result res = db.execute("MATCH (n:Avion {numero:"+pos+"}) RETURN n.numero, n.type, n.capacite");
    String test[] = {"n.numero", "n.type", "n.capacite"};
    Map<String, Object> obj = new LinkedHashMap();
    while(res.hasNext()) {
        Map<String, Object> row = res.next();
        for (String t:test) {
            obj.put(t, null);
        }
        for(Map.Entry<String, Object> col : row.entrySet()) {
             obj.put(col.getKey(),col.getValue());   
        }
    }
    res.close();
    typef.setText(obj.get("n.type").toString());
    capacitef.setText(obj.get("n.capacite").toString());

}
项目:codemodel-rifle    文件:GraphWalker.java   
public GraphWalker(DbServiceDecorator dbServices, long rootId, boolean simple, boolean cfg) {
        this.simple = simple;
        this.cfg = cfg;

        final Node root = dbServices.getNodeById(rootId);
        nodes.add(root);

        final Result result = dbServices.execute(
                "MATCH (root)-[*]->(n) WHERE id(root) = $rootId RETURN id(n) as id",
                ImmutableMap.of("rootId", rootId)
            );

        while (result.hasNext()) {
            final Map<String, Object> next = result.next();
            nodes.add(dbServices.getNodeById(Long.valueOf(next.get("id").toString())));
        }

//            nodes = dbServices.graphDb
//                    .traversalDescription()
//                    .breadthFirst()
//                    .traverse(root)
//                    .nodes()
//                    .stream().map(node -> node).collect(Collectors.toList());
    }
项目:WhiteLab2.0-Neo4J-Plugin    文件:CypherExecutor.java   
private void executeQuery(JsonGenerator jg, Query query) throws IOException {
    query.setStart(System.currentTimeMillis());
    try ( Transaction ignored = database.beginTx(); Result result = database.execute(query.toCypher()) ) {
        query.setEnd(System.currentTimeMillis());
        jg.writeNumberField("duration", query.getDuration());
        if (!query.isCountQuery())
            jg.writeArrayFieldStart(query.getResultHeader());
        while ( result.hasNext() ) {
            Map<String, Object> row = result.next();
            if (!query.isCountQuery())
                jg.writeStartObject();
            for ( Entry<String, Object> column : row.entrySet() ) {
                writeField(column, jg);
            }
            if (!query.isCountQuery())
                jg.writeEndObject();
        }
        if (!query.isCountQuery())
            jg.writeEndArray();
    }
}
项目:doc2graph    文件:DocumentRelationBuilderByKey.java   
@Override
public Set<Node> deleteRelations(DocumentRelationContext context) {
    Set<Node> orphans = new HashSet<>();

    String documentKey = context.getDocumentKey();
    if(StringUtils.isBlank(documentKey))
    {
        return orphans;
    }

    Result result = db.execute("MATCH (p)-[r:"+documentKey+"]->(c) RETURN r");
    result.forEachRemaining((res)->{
        Relationship rel = (Relationship) res.get("r");
        Node parent = rel.getStartNode();
        Node child = rel.getEndNode();
        rel.delete();
        if(log.isDebugEnabled())
        {
            log.debug("Delete relation "+rel);
        }
        updateOrphans(orphans, parent);
        updateOrphans(orphans, child);
    });

    return orphans;
}
项目:doc2graph    文件:DocumentGrapherRecursive.java   
/**
 * Search into database if exists a node with documentId
 * @param label 
 * @param documentId
 * @return
 */
private Node findNodeIntoGraphDb(Label label, DocumentId documentId) {
    Node node = null;

    //check if node already exists
    String query = "MATCH (n:"+label.name()+" {"+documentId.toCypherFilter()+"}) RETURN n";
    if(log.isDebugEnabled())
    {
        log.debug(query);
    }

    Result result = db.execute(query);
    while (result.hasNext()) {
        Map<String, Object> row = result.next();
        node = (Node) row.get("n");
        if(log.isDebugEnabled())
        {
            log.debug("Found: "+node);
        }
    }
    return node;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@Override
public Iterable<Edge> getAllEdges() {
    List<Edge> list = new ArrayList<>();
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.INDEX");
        while (result.hasNext()) {
            Map<String, Object> row = result.next();
            Relationship rel = (Relationship) row.get("r");

            Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
            Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));

            Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
                    (int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
                    v1,
                    v2);
            list.add(edge);
        }
    } finally {
        endTransaction();
    }
    return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@Override
public Iterable<Edge> getAllEdgesSortedByWight() {
    List<Edge> list = new ArrayList<>();

    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.WIGHT ASC");
        while (result.hasNext()) {
            Map<String, Object> row = result.next();
            Relationship rel = (Relationship) row.get("r");

            Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
            Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));

            Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
                    (int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
                    v1,
                    v2);
            list.add(edge);
        }
    } finally {
        endTransaction();
    }
    return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@Override
public Iterable<Edge> getAllEdgesSortedByWightDesc() {
    List<Edge> list = new ArrayList<>();
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.WIGHT DESC");
        while (result.hasNext()) {
            Map<String, Object> row = result.next();
            Relationship rel = (Relationship) row.get("r");

            Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
            Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));

            Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
                    (int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
                    v1,
                    v2);
            list.add(edge);
        }
    } finally {
        endTransaction();
    }
    return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@Override
public boolean edgeExist(long id1, long id2, int level) {
    if (level == 0) {
        return edgeExist(id1, id2);
    }
    boolean res = false;
    try {
        Result result = graphDb.execute("MATCH (a:COARSEN_NODE{INDEX:" + String.valueOf(id1) + ", LEVEL:" + level + "})-[r:LINK]-(b:COARSEN_NODE{INDEX:" + String.valueOf(id2) + ", LEVEL:" + level + "}) 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;
        }
    } finally {
        endTransaction();
    }

    return res;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@Override
public Iterator<Integer> getPartitions() {
    List<Integer> list = new ArrayList<>();
    try {
        beginTransaction();
        Result result = graphDb.execute("MATCH (n:NODE) RETURN DISTINCT n.PARTITION ORDER BY n.PARTITION");
        while (result.hasNext()) {
            Map<String, Object> row = result.next();
            int partition = (int) row.get("n.PARTITION");
            list.add(partition);
        }
    } finally {
        endTransaction();
    }
    return list.iterator();
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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);

}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
@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;
}
项目:GraphClustering    文件:NetworkNeo4j.java   
public double getVertexLocalClusteringCoefficient(long index) {
    double value = 0;

    try {
        beginTransaction();

        Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + index + "})--(b:NODE), (c:NODE{INDEX:" + index + "})--(d:NODE), (c)--(e:NODE), (d)-[r]-(e) "
                + "RETURN count(distinct(b)) AS k, count(distinct(r)) AS num");

        if (result.hasNext()) {
            Map<String, Object> row = result.next();
            Long k = (Long) row.get("k");
            Long num = (Long) row.get("num");

            if (k > 1) {
                value = (2 * num.doubleValue()) / (k.doubleValue() * (k.doubleValue() - 1));
            }
        }

    } finally {
        endTransaction();
    }

    return value;

}
项目:GraphClustering    文件:NetworkNeo4j.java   
public double getVertexLocalClusteringCoefficient(long index, int partition) {
    double value = 0;

    try {
        beginTransaction();

        Result result = graphDb.execute("MATCH (a:NODE{INDEX:" + index + ", PARTITION:" + partition + "})--(b:NODE{PARTITION:" + partition + "}), (c:NODE{INDEX:" + index + ", PARTITION:" + partition + "})--(d:NODE{PARTITION:" + partition + "}), (c)--(e:NODE{PARTITION:" + partition + "}), (d)-[r]-(e) "
                + "RETURN count(distinct(b)) AS k, count(distinct(r)) AS num");

        if (result.hasNext()) {
            Map<String, Object> row = result.next();
            Long k = (Long) row.get("k");
            Long num = (Long) row.get("num");

            if (k > 1) {
                value = (2 * num.doubleValue()) / (k.doubleValue() * (k.doubleValue() - 1));
            }
        }

    } finally {
        endTransaction();
    }

    return value;

}
项目:SPADE    文件:GetChildren.java   
@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;
}
项目:SPADE    文件:Neo4j.java   
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;
}
项目:SPADE    文件:Neo4j.java   
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;
}
项目:SPADE    文件:GetParents.java   
@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;
}
项目:SPADE    文件:Neo4j.java   
@Override
public Result executeQuery(String query)
{
    Result result = null;
    globalTxCheckin();
    try
    {
        result = graphDb.execute(query);
    }
    catch(QueryExecutionException ex)
    {
        logger.log(Level.SEVERE, "Neo4j Cypher query execution not successful!", ex);
    }
    finally
    {
        globalTxFinalize();
    }
    return result;
}
项目:SPADE    文件:Neo4j.java   
@Deprecated
private Set<AbstractEdge> prepareEdgeSetFromNeo4jResult(Result result, String childVertexHash, String parentVertexHash)
{
    Set<AbstractEdge> edgeSet = new HashSet<>();
    while(result.hasNext())
    {
        AbstractVertex childVertex = getVertex(childVertexHash);
        AbstractVertex parentVertex = getVertex(parentVertexHash);
        AbstractEdge edge = new Edge(childVertex, parentVertex);
        Map<String,Object> row = result.next();
        for (String key : result.columns())
        {
            edge.addAnnotation(key, row.get(key).toString());
        }
        edgeSet.add(edge);
    }

    return edgeSet;
}