title: Creating tree structure in Neo4j
body: <p>I am trying to create tree structure in Neo4j with Cypher Query.</p>
  
  <p>I am loading data from CSV to graph.</p>
  
  <p>Data structure is. Its having two Column that is Parent and Child</p>
  
  <p>P1,C1</p>
  
  <p>P1,C2</p>
  
  <p>P1,C3</p>
  
  <p>C1,SC1</p>
  
  <p>C1,SC2</p>
  
  <p>C2,SC3</p>
  
  <p>C3,SC4</p>
  
  <p>SC1,SSC1</p>
  
  <p>SC2,SSC2</p>
  
  <p>And so on....</p>
  
  <p>Here P is 1st level(Parent, parent 1) and C is Child, SC is Sub-Child and SSC is Sub-Sub-Child,
  I want to Load the data and create tree structure from top-to bottom</p>
  
  <p>I have used this Query but not getting the tree structure.</p>
  
  <pre><code>LOAD CSV  FROM 'file:C:/Users/ykumarx077781/Desktop/parent.csv' AS line
  
  CREATE (Parent:Parent { Parent: line[0]} )
  
  CREATE (Child:Child { Child: line[1]} )
  
  CREATE (Parent)-[R:Parent_off]-&gt;(Child)
  
  return R;
  </code></pre>
  
  <p>Please help me out to create the structure..</p>
  
  <p>Also used MERGE but did not get </p>
  
  <pre><code>LOAD CSV  FROM 'file:C:/Users/ykumarx077781/Desktop/parent.csv' AS line
  
  MERGE (Parent:Parent { Parent: line[0]} )
  
  MERGE (Child:Child { Child: line[1]} )
  
  CREATE (Parent)-[R:Parent_off]-&gt;(Child)
  
  return R;
  </code></pre>