cancel
Showing results for 
Search instead for 
Did you mean: 

Extract specific subgraph and create appropriate .csv files to re-import it in a new db

and_manousakis
Node Clone

I have a set of nodes extracted from a network bitcoin transaction network using the following query:

MATCH (root:Address {AddressID: $val})-[r*..k]->(target:Transaction)
RETURN DISTINCT(target.Hash) AS Targets

where k = 1, 3 and 5 (i.e. hops away from the root node). The result is a set of nodes (~210000) in a .csv file with two columns: [k, TxHash]

I would like to create the relationship files between the extracted nodes. The easiest way would be to create a nested for loop in the following manner:

q1 = """
	MATCH (src:Transaction {Hash: $val1})-[op:OutgoingPayment]->(a:Address)-[ip:IncomingPayment]->(dst:Transaction {Hash: $val2})
	RETURN DISTINCT(dst.Hash) AS Target
	"""

for src in neighbors:
	for dst in neighbors:
		output = graph.run(q1, parameters = {"val1": str(src), "val2": str(dst)}).to_data_frame()

Even though it's the easiest way, it will also take a lot of time. Is there some other more efficient way to achieve this?

Thank you!

P.S. The overall goal is starting from a seed node to visit its neighbors for k = 1, 2, ..., n and create the appropriate .csv files for bulk import in neo4j. In other words, identify a specific subgraph, create the appropriate .csv files and re-import it in a new neo4j db.

0 REPLIES 0