Tried to answer it with a Graphgist, does this look helpful?

http://gist.neo4j.org/?8972183

/peter

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 2.0.0                                  - (graphs)-[:FOR]->(everyone)
Kids LAN creative party in Malmö  - Kidscraft ICE


On Thu, Jan 9, 2014 at 9:52 PM, Devin Gaffney <[email protected]> wrote:
> Hey all!
>
> I'm just getting started with Neo4j and it's been super fun, but I've hit a
> wall I don't know how to navigate around - here's the gist of what I'm
> trying to do:
>
> I have networks, which have many "egos" that appear in those networks. These
> egos, in turn, occur in many different networks - basic many-to-many
> relationship, and in the context of a graph db, a bipartite network. In
> practice, my data looks something like this (pardon whatever silly format
> I'm about to write it as):
>
> Network 1: [Ego 1, Ego 2, Ego, 3, Ego 4]
> Network 2: [Ego 2, Ego 4, Ego, 5, Ego 6]
> Network 3: [Ego 4, Ego 5, Ego, 7, Ego 8, Ego 9, Ego 10]
> What I would like *out* of this data is something like the following:
>
> I want to know the relationship that Network 1 has with Networks 2 and 3.
> Specifically, I want to measure the overlap in a specific way - the count of
> the intersection of egos for two networks divided by the count of the union
> of egos. In other words, a comparison of Network 1 and Network 2 would yield
> the following steps:
>
> intersection = [Ego 2, Ego 4], 2 total
> union = [Ego 1, Ego 2, Ego 3, Ego 4, Ego 5, Ego 6], 6 total
> intersection/union = 1/3
>
> I would then say that these two networks are 33% similar (I'm open to other
> ways to calculate similarity in the spirit of what I'm trying to do here).
>
> For reference, the query I've got right now can pull out the intersection
> but not the union - also, any hints/tips about indexing/cypher query
> improvement/server optimization is very welcome.
>
> The query in question:
> MATCH (network:Network {id:
> '52acc273bf34801f89068a5a'})-[:appearance]->(ego:Ego)-[:occurrence]->(alter_network:Network)
> return distinct(alter_network.id), count(ego)
>
> Thanks much! Loving my experience so far,
>
> Devin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to