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

  • Home
  • SEARCH
  • 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 658957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:59:26+00:00 2026-05-13T22:59:26+00:00

This is a graph whose nodes exist in many connected components at once because

  • 0

This is a graph whose nodes exist in many connected components at once because a node’s relationships are a collection of edge groups such that only one edge per edge group can be present at once. I need to be able to find all of the connected components that a node exists in. What would be the best way to store this graph in neo4j to quickly find all of the connected components that a node exists in? Is there a way to use the built in traversals to do this?

Also: is there a name for this kind of graph? I’d appreciate any help/ideas.

Update:

Sorry for not being clear. All nodes are of the same type. Nodes have a variable number of edge groups. Exactly one edge from each edge group needs to be chosen for a particular connected component. I’m going to try to explain through example:

Node x1 is related to: (x2 or x3 or x4) AND (x5 or x6) AND (x7)
Node x2 is related to: (x8) AND (x9 or x10)

So x1’s first edge group is (x2, x3, x4), its second edge group is (x5, x6), and its third edge group is (x7).

So here are a few connected components that x1 exists in:

CC1:

x1 is related to: x2, x5, x7
x2 is related to: x8 x9 

CC2:

x1 is related to: x2, x6, x7
x2 is related to: x8, x9

CC3:

x1 is related to: x3, x5, x7

CC4:

x1 is related to: x3, x6, x7

etc.

I’m grateful for your help in this.

Update2:

I think I’ll be able to do this if there’s an answer to this question:
How can I specify which relationship type to use as a function of the current node at every step of a traversal with neo4j?

  • 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-05-13T22:59:26+00:00Added an answer on May 13, 2026 at 10:59 pm

    They way I understand your question you have a number of nodes, let’s call them X nodes, that are connected to a number of type nodes (or something similar), let’s call these nodes T nodes. An X node can have connections to multiple T nodes, but only one connection to each T node, or possibly only one connection to each kind of T node (your description is a bit fuzzy here).

    The way I would model this is by using one RelationshipType for each (kind of) T node. Then you can use x_node.getRelationships(T_TYPE_ONE, T_TYPE_TWO, …etc…) to get all the T nodes from an X node. When you mutate an X node is where you need to maintain your invariant that it can only have at most one relationship to each (kind of) T node. You do this by using x_node.getSingleRelationship(THE_T_TYPE_YOURE_MUTATING), if that returns null, it’s safe to add a new relationship of that type, if it returns a relationship, you will have to remove it before you can add the new one.

    ASCII-art example of this model (as I interpret it):

    (x1)--T_ONE-->(t1a)   (t1b)<--T_ONE--(x2)--T_FOUR-->(t4a)
     |\                                   |
     \ |---T_TWO-->(t2a)                 /
      \                                 /
       |---T_THREE-->(t3a)<--T_THREE---/
    

    In the example above both X nodes are part of T_ONE components, but x1 is part of T_ONE component t1a and x2 is part of t1b. They are both part of T_THREE component t3a, then x1 is part of T_TWO component t2a, and x2 is part of T_FOUR component t4a. Querying in this example would look something like:

    Iterable<Relationship> x1_comps = x1.getRelationships(T_ONE, T_TWO, T_THREE, T_FOUR);
    Iterable<Relationship> x2_comps = x2.getRelationships(T_ONE, T_TWO, T_THREE, T_FOUR);
    

    And updating would look like this:

    void setComponent(Node xNode, RelationshipType tType, Node tNode) {
        Relationship current = xNode.getSingleRelationship(tType);
        if (current != null) current.delete();
        xNode.createRelationshipTo(tNode, tType);
    }
    

    Please let me know if I’ve misinterpreted your requirements, and I’ll be happy to give your updated description a stab.

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

Sidebar

Ask A Question

Stats

  • Questions 455k
  • Answers 455k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The best way in my opinion is to use JSON… May 15, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer You can't resize a background image using CSS (unless you're… May 15, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer This should be reasonably fast: a = [] STDIN.each_char do… May 15, 2026 at 10:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.