load_edges_to_neo4j: load_edges_to_neo4j

Description Usage Arguments Details Value Examples

Description

Write a data.frame of edges/relationships to Neo4j.

Usage

1
2
3
4
5
6
7
8
load_edges_to_neo4j(
  df.with.labels.as.colnames,
  a.unique.poperty,
  b.unique.poperty,
  relationship_in_cypher,
  neo.import.dir,
  periodic_commit = "10000"
)

Arguments

df.with.labels.as.colnames

A data.frame of two columns, with node labels as column names. Eg. "Client". It's ok for both columns to have the same name if they are the same kind of node. If a column is unnamed, I ~think~ it will match a node of any label with the unique property value you define.

relationship_in_cypher

The relationship to create between the nodes in the first and second columns, written in Cypher code. Relationships can be directed or undirected, and they can be labeled or unlabeled. Cypher is not case-sensitive.

  • For directed relationships, the head of the arrow indicates direction: eg. if A LIKES B, use "-:Likes->" eg. if B LIKES A, use "<-:Likes-" eg. to define an unlabeled directed relationship from A towards B, use "–>"

  • For mutual or undirected relationships, no arrow is needed. eg. if A and B have met, use "-:Has_Met-"

NOTE: Only one relationship label can be defined at a time. eg. if everyone in columns A and B have met and each pair likes the other, run the function once with "-:Has_Met-" and run it a second time with "-:Likes-"

~ I hope to add a column for edge weights or other variable properties in the next version.

neo.import.dir

The directory location of the Neo4j import folder.

a.unique.property

The name of a unique property for nodes in the first column. Eg. "Client_ID". Use the name of the unique property exactly as you defined it when you created the nodes.

b.unique.property

The name of a unique property for nodes in the second column. Eg. "Client_ID"

Details

This function allows you to write a data.frame of edges/relationships to connect nodes in Neo4j.

Note: The column names of the df must identify the label(s) for the type(s) of nodes you are connecting, but the contents of the columns are unique ID values.

For exammple, the first column might be named "Person" and the values in that column are the value you defined using Unique_ID_col when creating the nodes (See: ?load_df_to_neo4j).

Value

The function writes a .csv file in your Neo4j database import directory, then loads the data to Neo4j. Once done, the .csv file is no longer needed, and it will be overwritten the next time the function is used.

Examples

1
2
3
4
5
6
7
load_edges_to_neo4j(
   df,
   a.unique.property = "Customer_ID",
   b.unique.property = "Item_SKU",
   relationship_in_cypher = "-[:PURCHASED]->"
)
# eg. The df might be two columns named "Customer" and "Product" if those are your node labels

brendan-newlon/df2neo4j documentation built on Sept. 19, 2020, 5:44 a.m.