def test_copy_graph(self):
		edges = set([(1,2),(1,3),(2,3)])
		g = digraphtools.graph_from_edges(edges)
		gg = digraphtools.copy_graph(g)
		self.assertEqual(g,gg)
		gedges = set(digraphtools.iter_edges(g))
		ggedges = set(digraphtools.iter_edges(gg))
		self.assertEqual(gedges,ggedges)
		gg[2].remove(3)
		self.assertNotEqual(g,gg)
		gedges = set(digraphtools.iter_edges(g))
		ggedges = set(digraphtools.iter_edges(gg))
		self.assertNotEqual(gedges,ggedges)
Exemplo n.º 2
0
 def find_goal_nodes(cls, items):
     '''return the set of all nodes that aren't depended on'''
     graph = cls.graph_from_items(items)
     start_nodes, dependencies = zip(*list(digraphtools.iter_edges(graph)))
     return set(start_nodes).difference(dependencies)
	def test_iter_edges(self):
		edges = set([(1,2),(1,3),(2,3)])
		g = digraphtools.graph_from_edges(edges)
		gedges = set(digraphtools.iter_edges(g))
		self.assertEqual(edges,gedges)
Exemplo n.º 4
0
	def find_goal_nodes(cls, items):
		'''return the set of all nodes that aren't depended on'''
		graph = cls.graph_from_items(items)
		start_nodes,dependencies = zip(*list(digraphtools.iter_edges(graph)))
		return set(start_nodes).difference(dependencies)