cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Create arcs between nodes with same label

Hi, I have the following problem. I developed a code on Spark/Python for k-medoids. Now I've managed to load the medoids that come from python directly into neo4j, meaning that spark communicates with neo4j. I also uploaded the data from a csv to neo4j. Both medoids and data have a final label. What I want to do is connect only nodes corresponding to data (each node is a row of this data table) and nodes corresponding to medoids so that each medoid only corresponds to nodes that share the same label as the medoid. I tried everything but it doesn't work with classic queries. You can help me?
2 REPLIES 2

Hello @Andrexx 😊

Can you share some code and data please?

Regards,
Cobra

I obtain a list of medoids from my code in python boxed in :

“medoidi_ottimi”.

 This contain 10 elements and each element appears like that :

[47, 100, 27, 81, 57, 37, 26, 0, 0, 23, 56, 53, 100, 90, 40, 98, 8]

Each element is a point of an original dataset and the numbers are properties. The last number( 8 in this case) is the “class”.

Now:

  1. From Python I load directly these medoids, all that works.
  2. In Neo4J I load the  original dataset using “load csv” command and that works.

Problems:

  1. a) these medoids  are points of the original dataset also, I would make evident them in the points of the dataset but instead the import in Neo4J add them as new points.

(Example, I have 10992 point in data set, 10 medoids, I would make evident these 10 medoids in the 10992 points and not simply add them to the points).

b) I would link by arc only the points and medoids with the same “class”labels, for example if the class of medoids is 4, I search all the points with class=4 and link to him, and this for each medoid.

This is my “very simple” code, because I’m new in Neo4J:

match(m:medoids),(p:points) WHERE m.class_ = p.class create (m)-[:BELONGS_TO]->(p)

but it doesn’t work.

I hope you help me.

 

Thank you 🙂