Hi Mohana,

Since you mention the movies dataset, I could make a few suggestions using
that. For example, if you want to know if a node is densely connected, you
could query on number of relationships. In the movies dataset a command
could be:

MATCH (m:Movie)<-[r]-()
RETURN m.title as Movie, count(r) as People
ORDER BY People DESC


This will list the movies with the most actors at the top. In your case a
similar command would like crimes that are nearby other crimes. Here is
another example from the movies dataset:

MATCH p=(m:Movie)<--()-->(n:Movie)
WHERE NOT m = n
RETURN m.title as Movie, count(p) as Related_Movies
ORDER BY Related_Movies DESC


This one will return movies that share common actors, ordered by the degree
of commonality, so movies that had actors in common with many other movies
would rank highest (I used 'WHERE NOT m = n' to make sure we only compared
movies with other movies, not with themselves). Your case had additional
constraints. You also wanted to compare crimes to crimes of different
types. We can simply keep adding constraints to the query. Here is an
example where I want to compare movies to only movies that were released
more than 10 years apart.

MATCH p=(m:Movie)<--()-->(n:Movie)
WHERE NOT m = n
AND abs(m.released - n.released) > 10
RETURN m.title as Movie, count(p) as Related_Movies
ORDER BY Related_Movies DESC


If you want to see the other nodes in the clique, not just the counts (like
I used above), then use the collect() function:

MATCH p=(m:Movie)<--()-->(n:Movie)
WHERE NOT m = n
AND abs(m.released - n.released) > 10
RETURN m.title as Movie, count(p) as Related_Movies, collect(n.title) as
Other
ORDER BY Related_Movies DESC


I hope these examples help your case. A great reference is the Cypher
documentation at:

   - http://docs.neo4j.org/chunked/stable/cypher-query-lang.html
   - http://docs.neo4j.org/refcard/2.1/

Regards, Craig


On Sun, Sep 7, 2014 at 8:16 PM, Mohana Krishna <[email protected]> wrote:

> Hello Craig,
>
> I need a help from you. I want to query my graph so that I get cliques of
> different sizes. Is there any inbuilt support or a way to formulate the
> query? I have been trying for long but unsuccessful.
>
> I have posted the issue in separate post but none replied. I am putting
> before you my exact case:
>
> 1) I have a graph where each node corresponds to a crime incident (with
> lat-lon information). Each crime incident (node) is *labelled* with
> crime_type (murder, robbery etc. in lines of actor, director for a movie
> database).
>
> 2) Two nodes are joined by a relationship if crimes represented by two
> nodes happen within 10KM of distance.
>
> 3) It is trivial to find 2 crime incidents(nodes) of two different labels
> which are having a relationship (query is simple)
>
> 4) Now I wish to find 3 crime incidents of three different labels such
> that there is relationship between every two of them. So, they essentially
> form a clique.  Similarly I wish to find 4,5,..n crime incidents such that
> for each size for each result all of incidents form a clique(all within
> 10KM) and they belong to different crime type.
>
> My result would be (n1,n2,n3) such that n1 and n2 happened within 10KM (so
> there is a relationship), n2 and n3 happened within 10KM (so there is a
> relationship), n1 and n3 happened within 10KM (so there is a relationship)
> - Essentially n1,n2,n3 form a clique of size-3. Moreover n1,n2&n3 each
> belong to a different crime type (no two of them are of same crime type)
>
> I hope I am clear. Please help me out by suggesting an efficient way to do
> it. Thanks in advance.
>
>
>
> On Tuesday, 12 August 2014 20:00:01 UTC+5:30, Mohana Krishna wrote:
>
>> Hello,
>>
>> I have loaded the spatial data in the attached file using REST API script
>> (which is also attached). The nodes are created and I can visualize them on
>> DB.
>>
>> However when I perform the query
>>
>> "START n=node:geom('withinDistance:[41.8082, -87.7084, 10.0]') RETURN n"
>> in CYPHER window , I am getting "Unknown Error" as result.
>>
>> Please help.
>>
>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to