Set properties in apoc.nodes.link

Hey everyone!

Stuck on one thing
The procedure apoc.nodes.link works fine for me (I have a lot nodes of type, say, "Transaction", having inputs "Address"), and i wanna connect these inputs within each transaction
But the problem is that i want not only connect inputs for a current transaction, but also pass Transaction.timestamp to all these connections

And i can't figure out how
Groupping by is too slow, that's why i'm trying to use exactly this method

Anyone knows a fast solution?

I am sorry, I don’t quite understand. Can you provide your code or a diagram?

My fault, i'll try to provide with more info

Here on the photo you can see 1 Transaction node (orange), and addresses, people participating in it (Blue)

I wanna connect these people (Red edges) for each such transaction with several inputs for further GDS methods

CALL apoc.periodic.iterate(
"
MATCH
(tx:Transaction)
where
tx.input_count > 1

RETURN  id(tx) as tx_id

",

"
MATCH (tx:Transaction) <-[p:Payment]-(a:Address)
WHERE id(tx) = tx_id

WITH tx.hash as hash, tx.timestamp as timestamp, collect(a) as inputs, collect(id(a)) as inputs_ids 
CALL apoc.nodes.link(inputs, 'Cluster_links_experimental')

"
,
{batchSize: 1000, parallel: false}
)
YIELD total, errorMessages

And the method apoc.nodes.link works good (much faster than aggregating by edges)
But its problem is that it is not possible to pass Transaction parameters such as hash and timestamp to these relationships (is it?)

It would be great if the APOC method could either not only set Label, but also pass those parameters, or just could return the ids of created relationships - but not the case

So how can i do this?

Please let me know if im clear, really appreciate your help. Any help and ideas

You could roll your own linking, so you can set the relationship properties.

create(:X{id:0}),(:X{id:1}),(:X{id:2}),(:X{id:3})

match(n:X)
with collect(n) as nodes
unwind range(0,size(nodes)-2) as index
with nodes[index] as startNode, nodes[index+1] as endNode
merge(startNode)-[r:REL{a:0, b:"red"}]->(endNode)

Modifying your query to use this approach:

CALL apoc.periodic.iterate(
"
    MATCH (tx:Transaction)
    where tx.input_count > 1
    RETURN tx
",
"
    MATCH (tx)<-[:Payment]-(a:Address)
    WITH tx.hash as hash, tx.timestamp as timestamp, collect(a) as inputs, collect(id(a)) as inputs_ids
    unwind range(0,size(inputs)-2) as index
    with inputs[index] as startNode, inputs[index+1] as endNode, hash, timestamp
    merge(startNode)-[:Cluster_links_experimental{a:0, b:'red'}]->(endNode)
",
    {batchSize: 1000, parallel: false}
) YIELD total, errorMessages

Of course, set the relationship properties appropriately.

Thank you so much - it works good and pretty fast!

And while we are here
You've removed that condition (reteurning id(tx) in first subquery and comparing node id in the second subquery), but i've read this article:

So it says it's not the best way to do it? Or not the case?

There internal workings of the apoc.periodic.iterate procedure allow passing neo4j entities to the second query. It is shown in the first example.