示例#1
0
#!/usr/bin/env python

from classes import Node, Graph

graphobj = Graph()

n1 = Node(name="test")
graphobj.addNode(n1)
n2 = Node(name="Child1", parent=n1)
graphobj.addNode(n2)
n3 = Node(name="Child2", parent=n1)
graphobj.addNode(n3)
n1.addChildren(n2)
n1.addChildren(n3)

nodes = graphobj.nodes

print "^^^^^^^^^^^^^^^^"
selectnode = graphobj.getNode("Child2")
print selectnode.name
print "^^^^^^^^^^^^^^^^"

for eachnode in nodes:
    print eachnode.name
    children = eachnode.getChildren()
    if len(children) > 0:
        for i in children:
            print "name"
            print i.name
            print "Parent"
            print i.parent.name
示例#2
0
import sys, math
import random

#Global Variables
graphmaster = Graph()
population = Gene()
maxRun = 1
matingPool = []

#1 . Reconstruct Tree based on information from input collection
client = pymongo.MongoClient()
db = client.input

rootNodeCursor = db.inputCollection.find({"name": "Root"})
rootNode = Node(name="Root")
graphmaster.addNode(rootNode)
## Create the root Node
rootEle = rootNodeCursor[0]["children"]
for child in rootEle:
    newchild = Node(name=child, parent=rootNode)
    rootNode.addChildren(newchild)
    graphmaster.addNode(newchild)
""" Contains only the first level nodes """
nodes = graphmaster.nodes
"""Construct the rest of the tree """
for node in nodes:
    nodeName = node.name
    if (nodeName != "Root"):
        restNodes = db.inputCollection.find({"name": nodeName})
        #get the children
        if (restNodes.count() != 0):
示例#3
0
文件: main.py 项目: SatabdiG/FrontEnd
import pyscreeze
import pygame
import os
from classes import Node, Graph
import termios
import tty

#Global Variables
childOffsetX = 20
screenWidth, screenHeight = pyautogui.size()
print screenHeight
print screenWidth

graphMaster = Graph()
parentRoot = Node(name="Root")
graphMaster.addNode(parentRoot)


class Application(tk.Frame):
    def __init__(self, master=None):
        tk.Frame.__init__(self, master=None)
        self.grid()
        self.master.minsize(width=200, height=100)
        self.master.bind("<Key>", self.show)
        self.filename = ""
        self.height = 0
        self.width = 0
        self.listele = ()
        self.createWidjet()

    def quitFunc(self):
示例#4
0
import termios
import tty
import pymongo

""" Contains an Application that can be used to create a database for any UI device """


#Global Variables
childOffsetX = 10
screenWidth, screenHeight = pyautogui.size()
client = pymongo.MongoClient()
db = client.input

graphMaster = Graph()
parentRoot = Node(name = "Root")
graphMaster.addNode(parentRoot)
RootElems = []
## Construct the input Tree ###
# get root elem
emptyNode = [] 
seenNodes = []
rootelem = db.inputCollection.find({"name":"Root"})
for eachelem in rootelem:
    #create a Node
    childeelm = eachelem["children"]
    for eachchild in childeelm:
        if(graphMaster.getNode(eachchild) == "Not Found"):
            #create a node
            tmpchild = Node(name = eachchild, parent = parentRoot)
            parentRoot.addChildren(tmpchild)
            graphMaster.addNode(tmpchild)