Ejemplo n.º 1
0
count = 0


while 1:
	if count==0 or count==1:
		choice = raw_input("\n\nChoose:\n0. Exit\n1. Add a user\n")
	elif count>=2:
		choice = raw_input("\n\nChoose:\n0. Exit\n1. Add a user\n2. Add a friend link\n3. Check connectivity\n4. Check degree of connection\n")

	count = count+1

	if choice=='0':
		break
	elif choice=='1':
		username=raw_input("Enter a username:\t")
		b = createUser(username,g,m)
		if b.makeNode():
			print "User created"
		else:
			print "User already exists"
	elif choice=='2':
		user1,user2 = raw_input("Enter the usernames of each user seperated by a tab:\t").split('\t')
		c = createFriends(user1,user2,g,m)
		if c.makeLinks():
			print "Friendship link established"
		else:
			print "Either user doesn't exist or both names given are the same"
	elif choice=='3':
		print "Enter names seperated by Enter key. Press 0 to stop\n\n"
		l=[]
		while 1:
Ejemplo n.º 2
0
from createGraph import createGraph,createUser, createFriends
from queryGraph import checkConnectivity, getDegree

print "\n\nCreating the schema:\n"

a = createGraph()
g = a.createGraph()
m = a.createMapping()


print "\n\nTesting user creation:\n"


b = createUser("Immanuel Kant",g,m)
if b.makeNode():
	print "Node added successfully"
else:
	print "TEST CASE FAILED"

b = createUser("Elon Musk",g,m)
if b.makeNode():
	print "Node added successfully"
else:
	print "TEST CASE FAILED"

b = createUser("Voltaire",g,m)
if b.makeNode():
	print "Node added successfully"
else:
	print "TEST CASE FAILED"