Ejemplo n.º 1
0
	def find_groups_external(self, n):
		self.dendogram = community.generate_dendogram(self.G)
		level = int(n * (len(self.dendogram)-1))
		result =community.partition_at_level(self.dendogram, level)
		groupmap = {}
		for entry in result.iteritems():
			#print entry
			#print groupmap
			if entry[1] in groupmap:
				groupmap[entry[1]].append(entry[0])
			else:
				groupmap[entry[1]] = [entry[0]]
		colors = self.get_colorscheme(len(groupmap))
		return zip(colors, groupmap.values())
Ejemplo n.º 2
0
def find_groups(request, n):
	dajax = Dajax()
	s = request.session
	user = s['fbuser']
	G_wrapper = GraphWrapper(user.get_friend_ids(), user.get_friends_links())
	#Why does storing this in the session not work...?
	dendogram = community.generate_dendogram(G_wrapper.G)
	level = int(n * (len(dendogram)-1))
	print "Level: %s" % level
	result =community.partition_at_level(dendogram, level)
	groupmap = {}
	for entry in result.iteritems():
		#print entry
		#print groupmap
		if entry[1] in groupmap:
			groupmap[entry[1]].append(entry[0])
		else:
			groupmap[entry[1]] = [entry[0]]
	colors = G_wrapper.get_colorscheme(len(groupmap))
	response=zip(colors, groupmap.values())
	#dajax.alert("Level: %s" % level)
	dajax.add_data(response, 'grapher.colorGroups')
	return dajax.json()