Ejemplo n.º 1
0
	def topological_sorting(self):
		"""
		Topological sorting.

		@attention: Topological sorting is meaningful only for directed acyclic graphs.

		@rtype:  list
		@return: Topological sorting for the graph.
		"""
		return sorting.topological_sorting(self)
Ejemplo n.º 2
0
	def topological_sorting(self):
		"""
		Topological sorting.

		@attention: Topological sorting is meaningful only for directed acyclic graphs.

		@rtype:  list
		@return: Topological sorting for the graph.
		"""
		return sorting.topological_sorting(self)
Ejemplo n.º 3
0
      antisymmetric_check(nodes, edges), '\n')
print('- Is the binary relation R transitive?\n-',
      transitive_check(nodes, edges), '\n')
print('- Is the binary relation R negatively transitive?\n-',
      negatively_transitive_check(nodes, edges), '\n')
print('- Is the binary relation R a complete order?\n-',
      complete_order_check(nodes, edges), '\n')
print('- Is the binary relation R a complete preorder?\n-',
      complete_preorder_check(nodes, edges), '\n')

# tasks 11, 12
print('The strict relation P:\n')
print(strict_relation(nodes, edges), '\n')
print('The indifference relation I:\n')
print(indifference_relation(nodes, edges), '\n')

# tasks 13
groups, dictionary = topological_sorting(nodes, edges)
if groups is None:
    print(
        '- Topological sorting can not be done: the binary relation R reduced to one node...\n'
    )
else:
    print('- Topological sorting:\n')
    for group in groups:
        print('  ↓', group)
    print('  ... where', dictionary, 'are grouped cycles.\n')

# binary relation visualization
draw_graph(nodes, edges)