Neo4J traversal in correct order for two different relationships?

Neo4J traversal in correct order for two different relationships?

Content Index :

Neo4J traversal in correct order for two different relationships?
Tag : neo4j , By : SilverRuby
Date : November 23 2020, 01:01 AM

Does that help Using relationships() multiple times does not imply an order. Instead there is a internal list which relationships() adds something to.
To limit a certain relationship type to a certain depth, you need to implement and use your own PathExpander. The example below uses Java and implements the PathExpander using an anonymous inner class:
traversalDescription.expand(new PathExpander<Object>() {
    public Iterable<Relationship> expand(Path path, BranchState<Object> state) {
        switch (path.length()) {
            case 0:
                return path.endNode().getRelationships(
                    DynamicRelationshipType.withName("A") );
            case 1:
                return path.endNode().getRelationships(
                    DynamicRelationshipType.withName("B") );
                return Iterables.empty();

    public PathExpander<Object> reverse() {
        // not used for unidirectional traversals
        throw new UnsupportedOperationException();

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

What is the correct way to save relationships in Spring Data Neo4J?

Tag : spring , By : user96271
Date : March 29 2020, 07:55 AM
Hope that helps My mistake was that I was instantiating the class manually, therefore it was not spring managed. Adding the @Component annotation to the class and asking Spring to give me the class resolved the problem.
@Component // This is the line that saved the day!
public class Privilege {

    Neo4jOperations operations;

    @GraphId Long id;
    @StartNode User user;
    @EndNode Right right;

    public Privilege() {

    public void createRelationship(User user, Right right) {
        this.user = user;
        this.right = right;

    /*** Getters and Setters ***/
@Autowired ApplicationContext applicationContext;
Privilege privilege = applicationContext.getBean(Privilege.class);
privilege.createRelationship(user, ADMINISTRATOR);

Spring data neo4j: correct way to handle relationships?

Tag : java , By : Gerhard Miller
Date : March 29 2020, 07:55 AM
Any of those help Since you want to retrieve groups for a user, and users in a group, it makes sense to set up your object model as you describe in #1 and #2.
UNDIRECTED is not a good choice here because it implies that the relationship between user and group can be in any direction, and I'm guessing you don't want this in your graph model. It's good for relationships where you don't care about the direction (such as (user1)-[:FRIEND]-(user2)) but not otherwise. I'd use OUTGOING and INCOMING in either class depending on what your relationship between user and group actually is.

Using Neo4J Traversal API to perform traversal on Neo4J running on other machine

Tag : neo4j , By : Dmitry
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The Traversal API can only be used if the code is colocated with the data, otherwise it would usually be awfully slow. The problem is that it's not purely declarative, since you can provide implementations of PathExpander, Evaluator, etc. instead of only using pre-defined constants.
However, there are several ways of having this code colocated:

Neo4j count and order relationships to list of nodes

Tag : neo4j , By : nickthecook
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have a graph of people and items. The relationship is one to many (a:Person)-[:has]->(b:Item). For an input list of items, I am trying to get a list of people that have that item, ordered by who has the most items in the list. , Perhaps something like:
MATCH (a:Person)-[:has]->(b:Item)
RETURN a, count(b) ORDER by count(b) DESC

Neo4J order by count relationships extremely slow

Tag : neo4j , By : user170635
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to log query statement to Neo4j server, is it possible?
  • 32-bit Unicode strings in Neo4j
  • How to exclude relations in a query (graph shown in the browser)
  • Cypher Match node that has no relation to any node not in a list
  • Return multiple relationship counts for one MATCH statement
  • Unknown identifier error in nested FOREACH statement check
  • How to get all indexes attached to a given label in Neo4J 2.0 Cypher
  • neo4j query on number of matches in a set
  • Neo4j - Many count nodes by property value in the same cypher query
  • Trying to do a MATCH inside of a nested FOREACH list
  • Neo4j Cypher and nested WHERE condition
  • Compare property that can be a timestamp or FALSE
  • Neo4J Spatial: Add all Nodes to Layer
  • Expresssion to match the Neo4j node that satisfies two or more relations (AND) relation
  • Fix the structure of a Label
  • Combining results from multiple cypher match statements
  • Relationship that have all the multiple types in Neo4j
  • Neo4j: How to filter out nodes from a list of IDs?
  • How to get node by name in neo4j 1.9.3 by using Java API?
  • Trouble creating a node which includes a range
  • Reset node counter on neo4j-shell's dump
  • Naming relationships changes the results?
  • setting up Neo4j replication on two instances
  • Getting endNodes from a list of matched nodes
  • How to model postcode based search in Neo4j?
  • Cypher : return collections with unique nodes
  • queries regarding neo4j HA setup
  • How to realize a multi-client capability in Neo4j?
  • Cypher Query: Return type of relationship of paths with variable length
  • neo4j relationships between PK and FK
  • How to create Spatical Index in Neo4j?
  • Neo4j: error in adding relationships among existing nodes
  • Cypher query and multi-pass references
  • Neo4j - Relaunch the program always revert the value of new added data
  • Neo4j Cypher - Conditional writes on matches
  • Loop in cypher, UNWIND or FOREACH (Neo4j)
  • Neo4j HTTP API transaction timeout period
  • Neo4J - Ordering results (list of maps) by node property
  • Temporary creation of nodes and relationships?
  • How to delimit this cypher query because there is a syntax error caused by the label name
  • Not able to load relationships from CSV
  • Best practice to create a node with date for every day in one year with neo4j?
  • Broken Pipe Error when expand child relationships in neo4j browser
  • In neo4j, how to sort multiple lists?
  • Group & minimum relation property in Neo4j
  • Litte expressivity of Property Graphs compared to RDF Graphs due to lack of reification?
  • Using Negation operator in neo4j,
  • neo4j data modelling multiple labels for a node with hierarchy
  • Neo4J user profile data modeling
  • load from csv error on Neo4j - Unexpected end of input
  • How to write Cypher query with gremlin groovy?
  • Is it always good to create an ID for a node?
  • Are multiple vertex labels in Gremlin/Janusgraph possible, or is an alternative solution better?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com