2011/4/25 Chris Gioran <chris.gio...@neotechnology.com>: > If I understand you correctly, you want to create groups of your nodes > + relationships that exist in your graph. The way you do that depends > on some things. > > 1. What is the degree of logical separation you desire? If two nodes, > A and B have a relationship in common, will they always end up in the > same category? If not, should the relationship remain?* > 2. How do you plan to access those nodes? If you want to find out the > category of nodes and relationships as you iterate over your data, > then maybe a tagging property would work. If you want direct access to > the nodes that belong to a category, an option is a "supernode" which > represents that category and have it relate to every node that belongs > to it. > > Creating a tagging property has the advantage of being indexable and > works both on nodes and relationships. A "supernode" (the quotes are > justified since we are talking about a simple node that just receives > special semantics, not some inherently different node kind) is a more > graphy way of doing things and probably faster too. > Example of tagging property:
// Add Node resource = graphDb.createNode(); resource.setProperty( "category", "some category" ); categoryIndex.add( resource, "category", resource.getProperty( "category" ) ); // Get for ( Node resource : categoryIndex.get( "category", "some category" ) ) { // Each resource with that category } Example of having the tags as nodes with relationships to its group members: // Add // TODO: check if the category you're creating exists first, // or create all categories up front Node category = categoryIndex.get( "name", "some category" ).getSingle(); Node resource = graphDb.createNode(); resource.createRelationshipTo( category, CATEGORY ); // Get Node category = categoryIndex.get( "name", "some category" ).getSingle(); for ( Relationship rel : category.getRelationships( CATEGORY, Direction.INCOMING ) ) { Node resource = rel.getStartNode(); } Where the latter solution is traversal friendly, whereas the former isn't. > I am sure there are other ways and I would also like to see how people > categorize entities in their graphs. > > *What currently cannot be done is role-based "hard" separation of > nodes. Suppose there are two nodes, a and b with a relation a-->b. Say > a ends up in category A and b in category B and the relationship > stays. If someone with access to A accesses a, then she will be able > to access b, no matter what. > > cheers, > CG > > On Mon, Apr 25, 2011 at 9:53 PM, pooja naik <npooj...@yahoo.com> wrote: >> Hi Chris, >> Thanks for a prompt response. >> I am trying to create a Network Graph Infrastructure for SP 's , in such a >> way that they can lease out the parts of this network infrastructure to >> other small companies. >> This requirement make it necessary to create a logical boundary on the main >> Network graph , in other words to create a overlay graphs on the underlying >> physical graph. >> Does "categories" would still help me here? >> Is there any another way to do it? >> Let me know >> Thanks n Regards >> Pooja >> ________________________________ >> From: Chris Gioran <chris.gio...@neotechnology.com> >> To: Neo4j user discussions <user@lists.neo4j.org> >> Sent: Monday, April 25, 2011 11:34 AM >> Subject: Re: [Neo4j] Regarding Sub grouping In Graph DB >> >> Hi Pooja, >> >> what would qualify as a subcategory in your use case? >> >> The most straightforward thing I can come up with is a property in >> each node named "category" or something similar, that has an >> enumerated value (not a Java Enumeration but something treated as >> such) that would place the node in its category. This is one of many >> ways to go ahead, depending on what degrees of separation you want, >> flexibility etc. >> Could you elaborate a little on what you are trying to do? >> >> cheers, >> CG >> >> On Mon, Apr 25, 2011 at 9:27 PM, pooja naik <npooj...@yahoo.com> wrote: >>> Hi all, >>> >>> >>> I am using ne04j for a IP network resource graph in my project. >>> I would like to know whether there is a way to divide the graphical >>> network into sub categories in neo4j? >>> >>> Any help or pointers is appreciated. >>> >>> Thanks >>> Pooja >>> _______________________________________________ >>> Neo4j mailing list >>> User@lists.neo4j.org >>> https://lists.neo4j.org/mailman/listinfo/user >>> >> _______________________________________________ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> >> >> > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user