>> My problem is the following:
>> I have a bi-partite graph consisting of two kinds of entities (say Users
>> and Images). A User object can be related to Images by means of
>> USER_IMAGE relationships.
>> Following the design guidelines, I have mapped this scheme to Neo4j in
>> the following way:
>> ROOT
>>    -> USERS -> RootUser
>>                                    -> USER -> User1
>>                                    -> USER -> User2
>>    ....
>>    -> IMAGES -> RootImage
>>                                    -> IMAGE -> Image1
>>                                    -> IMAGE -> Image2
>>      ....
>>                                             UserX -> USER_IMAGE -> ImageY
>>
>> After I create my original graph in one go (by reading from a text file)
>> I want to add some additional relationships to it, namely IMAGE_IMAGE
>> relations which are calculated in the following way:
>> Such a relation (IMAGE_IMAGE) is created between two Image nodes as long
>> as there is at least one User object which is related to both of these
>> Image objects (by means of a USER_IMAGE relationship). That would be
>> fine, but I also want to have a property attached to such a Relationship
>> which quantifies the frequency of this relationship (i.e. the number of
>> User objects that are related to both of these Images). The naive
>> approach that I adopted to achieve this, was the following:
>>  1. Iterate through all users.
>>  2. For each user, get a list of all images to which this user is
>> related. Create a relationship between each possible pair. If such a
>> relationship already exists, then update its "frequency" property.
>> As you may imagine, step 2 is in dire need of the relationship indexing
>> scheme we were discussing. I couldn't think of a more efficient way to
>> achieve the same result.
>>
>>     
>
> Do you ever traverse the IMAGE_IMAGE relationship after they have been
> created or are they just there to quantify the frequency between given
> two different images? If not you could store that information on a
> separate node that is indexed with the two image URIs.
>
> If you need to traverse the IMAGE_IMAGE draw two of those
> relationships to the indexed node. For example:
>
> (IMAGE_A)-------IMAGE_IMAGE------------v
>                                                       (Node that has
> frequency count and indexed property with "IMAGE_A_IMAGE_B")
> (IMAGE_B)-------IMAGE_IMAGE------------^
>   
While this is a good idea to reuse the existing neo4j infrastructure for 
tackling the aforementioned problem, I am a bit hesitant in adopting it 
since it would bloat the size of a graph (number of nodes) by an order 
of magnitude (since each image object typically has ~10 IMAGE_IMAGE 
relations). Of course, neo4j can handle very large graphs, but I would 
prefer not to push it too much ;-) .
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to