CSC790_HW111.docx

CSC790_HW1

Encoding and traversing (through Python) the Neo4J network – a directed ascyclic graph (DAG) as shown below:

In this DAG, the definitions of the arrows (from parent to child) called relationships

· The black circle is a relationship called Mandatory

· The white circle is a relationship called Optional

· The white triangle grouping couple of children is a relationship called alternative (only one)

· The black triangle grouping couple of children is a relationship called OR (one to many)

· Consider the requires relationship as parent-child. Ex: Polygonize is the parent of OGR and the relationship between them is called Requires

Example: for parent-child relationships:

· RasterVectorProcessing node is the parent of the library child and the relationship between them is called Mandatory

· The library node is the parent of children: GDAL (the relationship here is Mandatory) and OGR (the relationship here is Optional)

· The ReadingAlgorithm node is the parent of two children. The relationship between it and the two children (CustomBlock) and NativeBlock) is called OR

· The Polygonize node is the parent of four children. The relationship between it and the four children (DeleteEmptyPolygons), (Dissolve), (AreaCalc) and (AddFields) is called Alternative

And so on ….

Create a CSV which contain 3 columns. The first is the parent node, the second is the child node, and the third one is the relationship type (property of the relationship). You can name the property type of a relationship as you want (ex. rType) with the value like Optional, Mandatory and so on following the graph. The nodes have a property called name so that the names of the nodes are displayed inside them and shown in the graph.

Example of how to create the CSV file:

Parent

Child

Relationship

root

RasterVectorProcessing

Mandatory

Library

GDAL

Mandatory

Polygonize

OGR

Requires

Polygonize

AddFields

Alternative

Polygonize

Dissolve

Alternative

ReadingAlgorithm

NativeBlock

OR

ReadingAlgorithm

CustomBlock

OR

OutputFormat

PNG

Optional

And so on ….

Load the CSV file into Neo4j Desktop by doing research on how to import a CSV to the program.

Hint: don’t use the CREATE statement in Cypher since it will create duplicates nodes that have the same name. Use MERGE statement instead. The Cypher code in Neo4J Desktop command line to create this DAG consists of only 4 statements.

Use Python to traverse the DAG you created through the CSV file and return only the parents even if there are duplicates names.

Submit the CSV file your created along with the Python file.

Don’t copy your code from another student, otherwise it will be considered as plagiarism.