get all nodes and relationships properties within closed circle
Tag : neo4j , By : Lord Zantor
Date : March 29 2020, 07:55 AM
will help you Starting with Stefans answer, for the minimum you would want to take the lengths of the paths into account. start n=node(*)
match p=n-[:SELLS_TO*1..5]->n
return p, lenght(p)
start n=node(*)
match p=n-[:SELLS_TO*1..5]->n
return n, min(lenght(p))
start n=node(*)
match p=n-[:SELLS_TO*1..5]->n
with n, collect(nodes(p)) as nodes, min(length(nodes(p))) as l
return n, head(filter(p in nodes : length(p) = l)) as shortest_circle,l
|
What are allowed properties on neo4j nodes and relationships?
Tag : neo4j , By : Kristian Hofslaeter
Date : March 29 2020, 07:55 AM
|
Creating relationships between nodes with same properties
Tag : neo4j , By : Ambarish Singh
Date : March 29 2020, 07:55 AM
wish of those help The query you wrote first creates a cartesian product between all pairings of person nodes, then does filtering on each pairing to find the ones that are actually related, then creates the relationship. That is very expensive, an n^2 operation. Instead, you may want to go through all Person nodes just once, and find the corresponding person node with the property, and create the relationship. match (p1:Person)
with p1
match (p2:Person)
where p2.someproperty = p1.someproperty and p1 <> p2
merge(p1)-[r:Relationship]-(p2)
|
Multiple relationships of the same type but with different properties between the same two nodes
Tag : neo4j , By : cashshadow
Date : March 29 2020, 07:55 AM
|
Can graph algorithms take nodes' and relationships' properties in Neo4J?
Tag : neo4j , By : mckasty
Date : March 29 2020, 07:55 AM
it helps some times You can use Cypher projection to be more selective about which nodes and relationships to process with an graph algorithm. For example, to execute the algo.pageRank algorithm only on Page nodes whose timestamp > 1000, and LINKS relationships that have a specific property x, this should work: MERGE (dummy:Dummy)
WITH dummy, ID(dummy) AS dummy_id
CALL algo.pageRank.stream(
'OPTIONAL MATCH (p:Page) WHERE p.timestamp > 1000 RETURN CASE WHEN p IS NOT NULL THEN ID(p) ELSE ' + dummy_id + ' END AS id',
'OPTIONAL MATCH (p1:Page)-[link:LINKS]->(p2:Page) WHERE EXISTS(link.x) WITH CASE WHEN link IS NOT NULL THEN [ID(p1), ID(p2)] ELSE [' + dummy_id + ',' + dummy_id + '] END AS res RETURN res[0] AS source, res[1] as target',
{graph:'cypher', iterations:20, dampingFactor:0.85})
YIELD node, score
WITH dummy, node, score
WHERE node <> dummy
RETURN node, score ORDER BY score DESC LIMIT 20;
|