Subversion Repositories programming

Rev

Rev 397 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 397 Rev 399
Line 31... Line 31...
31
		self.__name = str(name)
31
		self.__name = str(name)
32
		self.__graph = graph
32
		self.__graph = graph
33
 
33
 
34
	def render_stupid (self, prop=None):
34
	def render_stupid (self, prop=None):
35
		"""Print the graph using the not very good method of telling whether
35
		"""Print the graph using the not very good method of telling whether
36
		   we go up,down,left,right between every node."""
36
		we go up,down,left,right between every node.
-
 
37
		NOTE: This tells us HOW each node was generated, not the path taken
-
 
38
		through the graph. Use render_graphviz() for a MUCH improved visualization"""
37
		if prop == None:
39
		if prop == None:
38
			raise ValueError # no propery given
40
			raise ValueError # no propery given
39
 
41
 
40
		g = self.__graph
42
		g = self.__graph
41
		added = True
-
 
42
		count = 0
-
 
43
 
43
 
-
 
44
		# Get the vertices sorted in the order in which they were added to
44
		while added:
45
		# the graph.
-
 
46
		sorted_vertices = [(int (g.get_vertex_value (v)), g.vertices[v].raw_obj)
-
 
47
					for v in g.vertices.keys()]
45
			added = False
48
		sorted_vertices.sort()
46
 
49
 
47
			for v in g.vertices.keys():
50
		for v in sorted_vertices:
48
				if g.get_vertex_value (v) == str(count):
-
 
49
					print getattr (g.vertices[v].raw_obj, prop),
51
			print getattr (v[1], prop),
50
					added = True
-
 
51
 
52
 
52
			count += 1
53
		print
53
 
-
 
54
		print # nothing, to end the getattr() print above
-
 
55
		print '%d nodes in the solution' % len(g.vertices)
54
		print '%d nodes in the solution\n' % (len(g.vertices), )
56
 
55
 
57
	def render_graphviz (self, filename, layout_engine=yapgvb.engines.neato):
56
	def render_graphviz (self, filename, layout_engine=yapgvb.engines.neato):
58
		"""Draw the graph given into the file given. This will render
57
		"""Draw the graph given into the file given. This will render
59
		to SVG, PNG, and JPG."""
58
		to SVG, PNG, and JPG."""
60
 
59