skip to Main Content

So I have a csv with this header:

start_id,strength,start_verse,end_verse

Two line examples are these:

01001001,15,38012001,00000000
01001001,16,20008022,20008030

The first line means that the node with id 01001001 connects with strength 15 with the node id 38012001.

The second line means that the node id 01001001 connects with strength 16 to all the nodes between 20008022 and 20008030, sequentially, and here is where lies my problem:

How can I use Apache AGE to connect one vertex to all vertexes in a group?
I was using the load csv feature, but if anyone know any other means to do so, I am all ears.

2

Answers


  1. Unfortunately, Apache AGE currently does not have a function that creates edges in that way. However, you can use a Cypher query to establish relationships between vertices if they have a property like ‘id’ or any other distinguishing property.

    In this way, you can create the vertices using the ‘load_labels_from_file()’ function (more about it here), and then use a Cypher query like this:

    SELECT * FROM cypher('graph_name', $$
        MATCH (v {id: 01001001})
        CREATE (v)-[:connects {strength: 16}]->(n)
        WHERE n.id >= 20008022 AND n.id <= 20008030
    $$) AS (v agtype);
    
    Login or Signup to reply.
  2. Since there is currently no shortcut to achieve exactly what you are looking for, it may be easier to simply edit the CSV file to create new rows for each connections with strength 16, for example:

    start_id,strength,verse
    01001001,15,38012001
    01001001,16,20008022
    01001001,16,20008023
    01001001,16,20008024
    01001001,16,20008025
    01001001,16,20008026
    01001001,16,20008027
    01001001,16,20008028
    01001001,16,20008029
    01001001,16,20008030
    

    Which then you can just import into AGE. It is relatively easy to do this change rather than manually making the connection inside AGE in my opinion.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search