示例#1
0
from timeit import Timer
t = Timer(lambda: add_graph(5000, 5000, atlas))
print t.timeit(number=1)

logger.info("adding function to a vertex:")

alex = Vertex(atlas,
              properties={
                  "name_as_string": "alex",
                  "age_as_integer": 28
              }).save()
rand = Vertex(atlas,
              properties={
                  "name_as_string": "rand",
                  "age_as_integer": 28
              }).save()
mael = Vertex(atlas,
              properties={
                  "name_as_string": "mael",
                  "age_as_integer": 31
              }).save()

e1 = Edge(atlas, alex, rand, "friend", {}).save()
e2 = Edge(atlas, alex, mael, "friend", {}).save()
friends_of_friends = """me = g.v(_id)
friends = me.both('friend').toList()
me.both('friend').both('friend').dedup().except([me]).except(friends)
"""

print rand.execute(friends_of_friends, {})
示例#2
0
		nodes += [v]
	for i in range(ne):
		v1 = choice(nodes)
		v2 = choice(nodes)
		while v2 == v1:
			v2 = choice(nodes)
		e = Edge(handler, v1, v2, "likes", properties = {"how_much_as_integer" : 2})
		e.save()
logger.info("adding 5000 nodes and 5000 edges")
from timeit import Timer
t = Timer(lambda: add_graph(5000, 5000, atlas))
print t.timeit(number=1)



logger.info("adding function to a vertex:")

alex = Vertex(atlas, properties = {"name_as_string" : "alex", "age_as_integer" : 28}).save()
rand = Vertex(atlas, properties = {"name_as_string" : "rand", "age_as_integer" : 28}).save()
mael = Vertex(atlas, properties = {"name_as_string" : "mael", "age_as_integer" : 31}).save()


e1 = Edge(atlas, alex, rand, "friend", {}).save()
e2 = Edge(atlas, alex, mael, "friend", {}).save()
friends_of_friends = """me = g.v(_id)
friends = me.both('friend').toList()
me.both('friend').both('friend').dedup().except([me]).except(friends)
"""

print rand.execute(friends_of_friends,  {})