Re: [Neo4j] Graph traversal - applying actions to each node

2018-03-23 Thread 'Michael Hunger' via Neo4j
You can use triggers with apoc, that check e.g. when a node with label
:Yellow is added:

CALL apoc.trigger.add('create-new-yellow-node','
UNWIND apoc.trigger.nodesByLabel({createdNodes},'Yellow') AS this
MATCH (this)<-[:CHILD_OF*]-(p) WHERE p.value = this.value *SET ...*
', {phase:'before'})

Michael

On Tue, Mar 20, 2018 at 6:35 PM, Ynoa  wrote:

>
>
>
>- *Neo4j version*: 3.3.1 Enterprise
>- *Driver*: Javascript-driver
>- *Used Language*: Typescript / Angular 2
>- *OS*: Windows 10
>
>
>
> I have a series of nodes with RED being the Root-node, and YELLOW is
> always the parent of ONLY a green node (GREEN always the child of ONLY
> YELLOW).
>
> For this example the nodes contain a single char.
>
>
> 
>
>
>
>
> Each time a YELLOW node is created with a given value, I want to traverse
> the tree, and compare all visited nodes with the value in the newly created
> YELLOW-node. If they contain the same value, and then do something wether
> this is true or not.
>
>
>
> I have read about the traversal API (java only, apparently) which allows
> me to imperatively manage the traversal, and apply a function to each node
> visited (visitor function). This would be good to use in this case.
>
> But I use the javascript driver, and coding in Typescript, so I don't have
> this option. It seems I have to rely on Cypher, and here's my question(s):
>
>
>
>- Using Cypher, how do I control traversal in way, that I can apply a
>function to each visited node in a given tree?
>- Are there other ways of achieving the traversal if I can't do this
>with Cypher?
>
>
> Any help or links to helpful articles or the neo4j documentation would be
> greatly appreciated.  In the meantime, I will keep trying :)
>
> Kind Regards
>  Joe
>
> --
> 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 neo4j+unsubscr...@googlegroups.com.
> 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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] Counting INCLUDES in Traversal Framework

2018-03-23 Thread David Dupuis
Hi,

I'm currently coding my own Traverser. The objective is to perform a type 
of random walk on the graph and count the number of visited nodes.

To code the random walk part I create my own Evaluation function and pruned 
the graph as desired. 

To count I do the following:

long score = 0;
for (Node currentNode : traversal.traverse( nodeList ).nodes())
{
score += 1;
}

However, this doesn't always work as I would like and I was therefore 
wondering if there was a way to keep track of how many nodes we INCLUDE in 
the Evaluation function?

For instance I have a global score variable, and in the Evaluation function 
before I perform "return INCLUDE_AND_CONTINUE" or 
"return INCLUDE_AND_PRUNE" I increment score

Thanks,

-- 
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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] In Uniqueness.NODE_GLOBAL what does it mean to be visited?

2018-03-23 Thread David Dupuis
Hi, 

This is related to another question I asked recently. 

When randomly traversing a graph based on the probability of existence of 
an edge, using the Traversal Framework,  I would like to count the number 
of unique nodes visited.
We are in a breadth first setting.

Suppose we have the following graph:

(A)-[0.5]->(B)
(A)-[0.5]->(C)
(C)-[0.5]->(B)
(B)-[0.5]->(C)

If we start with (A) we have a probability of visiting (B) of 0.5 and of 
visiting (C) of also 0.5 . 

We start with (A) and add it to the visited nodes: [A]. By chance we visit 
B and so add it to the visited nodes [A, B]. From (A) we attempt to reach 
(C) but fail. (C) has not yet been visited. Now from (B) we attempt to 
reach (C) as it has not been visited yet and we succeed adding it to the 
list of visited nodes [A, B, C].

Above is one ideal example. If I use NODE_GLOBAL to solve this problem then 
when (A) attempts to reach (C), the evaluator will consider (C) has having 
been traversed and add it to the list of visited nodes therefore stopping 
(B) from attempting to reach (C). Therefore (C) will be impossible to 
reach. 

On the other hand, if I define NODE_PATH and RELATIONSHIP_GLOBAL then I 
sometimes get cycles or nodes visited twice. This is both strange 
considering NODE_PATH and also not what I want. 

So my question is: if in my evaluator I "return EXCLUDE_AND_PRUNE" does it 
add the excluded node to the list of visited nodes? If not what may be the 
source of this error and how can I fix it?

Thanks 


-- 
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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] Re: blockchain using graph database

2018-03-23 Thread William Ti'iti'i Asiata
It looks like bigchainDB is trying to build custom blockchains on top of DB 
systems - not sure whether graph or relational though

On Wednesday, December 7, 2016 at 1:24:22 AM UTC+13, ANAND BALAGOPAL wrote:
>
> Hi, Please let me know If you find any interesting links or Datas on the 
> same...I am also exploring the same field
>
> On Friday, September 30, 2016 at 1:35:17 PM UTC+5:30, koen wrote:
>>
>> Hi, i wonder if there already have been initiatives where a neo4j graph 
>> database is used as underlying technology for a blockchain implementation. 
>> I do not mean for analysing it (like you could do when importing for 
>> example the bitcoin blockchain into neo4j) but for storing the chain and 
>> data elements and processing. 
>>
>> Looking at for example the bitcoin blockchain with its blocks, 
>> transactions and addresses, wallets, users, and network components  it can 
>> be seen as one large graph. Looking at documentation for all sorts of 
>> blockchain implementations from multiple vendors  people always tend to use 
>> "graph" like / kind of pictures to illustrate (even if the underlying 
>> technology is not a graph db).. 
>>
>> Thanks Koen
>>
>

-- 
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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] Graph traversal - applying actions to each node

2018-03-23 Thread Ynoa





   - *Neo4j version*: 3.3.1 Enterprise
   - *Driver*: Javascript-driver
   - *Used Language*: Typescript / Angular 2
   - *OS*: Windows 10
   


I have a series of nodes with RED being the Root-node, and YELLOW is always 
the parent of ONLY a green node (GREEN always the child of ONLY YELLOW).

For this example the nodes contain a single char.






Each time a YELLOW node is created with a given value, I want to traverse 
the tree, and compare all visited nodes with the value in the newly created 
YELLOW-node. If they contain the same value, and then do something wether 
this is true or not. 



I have read about the traversal API (java only, apparently) which allows me 
to imperatively manage the traversal, and apply a function to each node 
visited (visitor function). This would be good to use in this case. 

But I use the javascript driver, and coding in Typescript, so I don't have 
this option. It seems I have to rely on Cypher, and here's my question(s):



   - Using Cypher, how do I control traversal in way, that I can apply a 
   function to each visited node in a given tree?
   - Are there other ways of achieving the traversal if I can't do this 
   with Cypher?


Any help or links to helpful articles or the neo4j documentation would be 
greatly appreciated.  In the meantime, I will keep trying :)

Kind Regards
 Joe

-- 
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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.