Thanks, Michael.  

Yes, the nodes ObjectConcept are indexed.  Yes, there was a direction 
missing in the original query, a typo on my part.  

All ObjectConcept nodes have an ISA relationship to their supertypes (a 
polyhierarchy).  Also, ObjectConcepts have defining relationships with 
other ObjectConcepts as necessary to disambiguate on ObjectConcept from 
another.


I did try this query:

MATCH p = (a:ObjectConcept{sctid:233604007}) <-[:ISA*]- (b:ObjectConcept), 
q=(c:ObjectConcept{sctid:58800005})<-[:ISA*]-(d:ObjectConcept) 
WHERE NOT (b)-->()--(c) AND NOT (b)-->()-->(d) 
RETURN distinct b 
UNION  
MATCH p = (a:ObjectConcept{sctid:233604007}) <-[:ISA*]- (b:ObjectConcept), 
t = (e:ObjectConcept{sctid:65119002})<-[:ISA*]-(f:ObjectConcept) 
WHERE NOT (b)-->()-->(e) AND NOT (b)-->()-->(f) 
RETURN distinct b

The correct results returns in 20 seconds vs. 20 minutes...a huge 
improvement, but I am sure that Neo can do better...with better query 
design.  

The goal of the query is to identify all distinct nodes in paths p, q, and 
h.  With those distinct nodes, the identification of a relationship between 
nodes(p) and nodes(q) and/or nodes(h) is desired. 

Thanks



On Friday, March 20, 2015 at 3:27:23 PM UTC-5, Scott Campbell wrote:
>
> I am working with an acyclic, directed graph (an ontology) that models 
> human health and am needing to identify certain diseases (example: 
> Pneumonia) that are infectious but NOT caused by certain bacteria (staph or 
> streptococcus).  All concepts are Nodes defined as ObjectConcepts. 
>  ObjectConcepts are connected by relationships such as [ISA], 
> [Pathological_process], [Causative_agent], etc. 
>
> The query requires:
>
>  a) Identification of all concepts subsumed by the concept Pneumonia as 
> follows:
>
> MATCH p = (a:ObjectConcept{Pneumonia}) <-[:ISA*]- (b:ObjectConcept)
>
> b) Identification of all concepts subsumed by Genus Staph and Genus Strep 
> (including the concept Genus Staph and Genus Strep) as follows.  Note: 
>
> with b MATCH (b) q = (c:ObjectConcept{Strep})<-[:ISA*]-(d:ObjectConcept), 
> h = (e:ObjectConcept{Staph})<-[:ISA*]-(f:ObjectConcept) 
>
> c) Identify all nodes(p) that do not have a causative agent of Strep 
> (i.e., nodes(q)) or Staph (nodes(h)) as follows:
>
> with b,c,d,e,f MATCH (b),(c),(d),(e),(f) WHERE (b)--()-->(c) OR 
> (b)-->()-->(d) OR (b)-->()-->(e) OR (b)-->()-->(f) RETURN distinct b.Name;
>
> The query returns the correct result, but runs for 20 min.  However, 
> running the same query without Strep or Staph concepts, the query returns a 
> correct result in < 0.5 seconds.  XOR operators also work when and/or 
> results are needed, but speed is still an issue.
>
> I am new to cypher, but I am sure that there is a more efficient query for 
> this problem.  I am unsure if/how collections and lists could be employed 
> and improve run times.  Suggestions?
>

-- 
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