liveBook · Manning

In_reply_to relationship

As explained in Graph Algorithms for Data Science

An in-reply-to relationship is a graph relationship indicating that one tweet was made in response to another tweet.

An IN_REPLY_TO relationship connects a tweet to the tweet it answers, representing response structure in a Twitter graph. It keeps replies distinct from retweets and quote tweets, whose different semantics support different analyses. section 3.2.2

Model and import the relationship as follows:

  • Create a directed relationship from the source tweet to the target tweet being answered. section 3.2.5
  • Store reply pairs in a CSV file with source and target tweet identifiers. section 3.2.5
  • Use MERGE during import so repeated rows do not create duplicate relationships. section 3.2.5

Import reply relationships with Cypher

LOAD CSV WITH HEADERS FROM "reply-data.csv" AS row MATCH (source:Tweet {id:row.source}) MATCH (target:Tweet {id:row.target}) MERGE (source)-[:IN_REPLY_TO]->(target); section 3.2.5

Figure 3.10 Differentiating between retweets and quotes by using different relationship types
03-10

A relationship diagram helps compare IN_REPLY_TO with RETWEETS and quote-tweet relationships. section 3.2.2

How Graph Algorithms for Data Science covers it

How deep it goes
Defines the relationship and demonstrates its Cypher import, while deferring reply-content analysis and omitting unavailable quote tweets.
Examples
Uses source-target CSV pairs and a Cypher MERGE query to create directed IN_REPLY_TO relationships between tweets.
What it assumes
Assumes tweet nodes already exist and teaches the reply relationship and its import pattern from basic graph-modeling assumptions.
What you can do after
Operate Neo4j to import directed reply relationships from CSV data using MATCH and MERGE.
How it connects
Connects tweet graphs with retweets, quote tweets, graph modeling, Cypher, CSV import, and sentiment analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.