from node import node
Tree = {}

def findNode(name = ""):
    for i in Tree.values():
        if i.name == name:
            return i

def searchNode(keys = []):
    matches = []  # list of matched node, (% matched, #matched, id)
    for i in Tree.values():
        matched = [k for k in keys if k in i.getKeywords()]
        if len(matched) !=0:
            matches.append([-float(len(matched))/len(i.keywords), -len(matched), i])
    
    matches.sort()
    return [i[2] for i in matches]
        
def addNode( name, keywords = set([]), content = '', parents = [], children = [] ):
    #print "Add node " + name
    Tree[node.count] = node( name, keywords, content, parents, children)

def delete( nodeID):
    Tree[nodeID].deleteConnections()
    del Tree[nodeID]

def setParentof(parID, childID):
    if parID in Tree and childID in Tree:
        Tree[parID].addChild(Tree[childID])
    else:
        print "Error - It is not on the Tree"
    


@@ -150,16 +150,46 @@
 (key
-s = %5B%5D):
+words):%0A    keys = keywords.split(' ')
 %0A   
@@ -533,32 +533,46 @@
 f addNode( name,
+ content = '',
  keywords = set(
@@ -576,29 +576,16 @@
 et(%5B%5D), 
-content = '',
  parents
@@ -722,18 +722,21 @@
 f delete
+Node
 (
- 
 nodeID):
@@ -803,19 +803,15 @@
 def 
-setParentof
+addEdge
 (par
@@ -966,14 +966,169 @@
 e Tree%22%0A
-    %0A
+%0Adef deleteEdge(parentID, childID):%0A    Tree%5BparentID%5D.removeChild(Tree%5BchildID%5D)%0A%0Adef editContent(nodeID, newContent):%0A    Tree%5BnodeID%5D.editContent(newContent)
 %0A

Rename functions