Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:54:31+00:00 2026-06-11T18:54:31+00:00

I have a graph where each node represents a java class and each one

  • 0

I have a graph where each node represents a java class and each one has a property called namespace. I want to match a pattern where the starting node and final node share a namespace but all intermediates do not share that namespace. for the case where theres 3 classes (Class A -> Class B -> Class C) i have:

START inside1 = node(*) 
match inside1 -[:USES]-> outside1 -[:USES] -> inside2  
where inside1.namespace <> outside1.namespace 
  and inside2.namespace = inside1.namespace  
return inside1.name, outside1.name, inside2.name

This seems to work fine. When I tried to expand it, I tried:

START inside1 = node(*) 
match inside1 -[:USES]-> outside1 -[:USES*] -> inside2  
where inside1.namespace <> outside1.namespace 
  and outside1.namespace <> inside1.namespace 
  and inside2.namespace = inside1.namespace  
return inside1.name, outside1.name, inside2.name

The problem is I dont want any paths where intermediate nodes share the same namespace as inside1. so my question is, is there anyway that I can tell it “stop when you hit a node whos namespace is equal to inside1.namespace”?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:54:33+00:00Added an answer on June 11, 2026 at 6:54 pm

    Not sure if it’s the most succinct, but I think this does what you want? First it gets the general case with your query, then it limits it to only the tightest match with a with.

     START inside1 = node(*) 
     MATCH inside1-[:USES*]->outside1-[:USES]->inside2 
     WHERE inside1.ns <> outside1.ns 
       AND inside2.ns = inside1.ns 
      WITH inside1, inside2, outside1 
     MATCH inside1-[:USES]->outside2 
     WHERE inside1.ns <> outside2.ns 
    RETURN inside1, outside1, inside2
    

    http://console.neo4j.org/r/m8iqo5

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a graph with four nodes, each node represents a position and they
I have the following simple Graph class, where for each Node , I store
I have a directed-graph, each node is a complex data type. Does anyone know
I want to Draw multiple line Graph with each line have different color and
Let's say I have a graph with heavy nodes, that is each node is
Basically I want to be able to have each node of type tree have
Given a n*n-sized multi-headed acyclic graph where each node has at most three children
I have a weighted graph with its nodes and edges. Each node contains a
I want to implement in Java a class for handling graph data structures. I
I have an undirected graph where each node contains an array. Data can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.