LoslegenKostenlos starten

Creating relationships

The Building Knowledge Graphs book has two authors, Jesus Barrasa and Jim Webber. In addition to the book node you already created, we've created two additional nodes defined as jesus and jim representing the two authors.

In this exercise, you'll create a WRITTEN_BY relationship between each author node and the book by looping over the author nodes.

Diese Übung ist Teil des Kurses

<Kurs>Graph RAG with LangChain and Neo4j</Kurs>
Kurs ansehen

Übungsanweisungen

  • Create a relationship of type "WRITTEN_BY" from the book node to each author node.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

from langchain_neo4j.graphs.graph_document import Relationship

relationships = []

for author in [jesus, jim]:
  	# Create a Relationship between book and each author
    relationships.append(____(
    	____=book, 
      	____=author, 
      	____="____"
    ))

visualize_graph([book, jesus, jim], relationships)
Code bearbeiten und ausführen