Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
TopologicalSort - compute a linear ordering consistent with a given partial ordering
Calling Sequence
TopologicalSort(rel::{list, set}([anything, anything]))::list
Parameters
rel
-
partial order specified as a list or set of pairs
Description
The procedure TopologicalSort attempts to produce a linear ordering of a collection of elements that is consistent with a specified partial ordering of those elements. This means that an element precedes an element in the partial order only if precedes in the linear order.
The partial order is specified as a ``relation'' rel, which is a list or set of pairs , each representing an ordering of the elements of the domain of the relation. A pair belongs to the relation rel if precedes in the partial order it represents. The domain of the relation is the set of all expressions that occur as either a first or second entry (or both) in some pair in the relation rel.
Alternatively, you may think of the members of rel as directed edges in a graph whose vertices are the elements of the domain of the relation. In these terms, a topological sort of the vertices is a linear ordering of them such that a vertex occurs before in the linear order only if there is a directed path from to in the graph. The two characterizations are equivalent.
In general, there may be many linear orderings of the vertices of a graph that are consistent with it. For example, the partial order (indicating that is "less than" and is "less than" has two consistent linear orderings: and . The TopologicalSort procedure produces one of them.
It is also possible that no linear ordering consistent with the given partial order exists. This is the case when the directed graph contains a cycle. If TopologicalSort detects a cycle in the graph, then an exception is raised. The simplest example of this is the relation , which clearly has no consistent linear order.
Examples
Error, (in TopologicalSort) graph is not acyclic
Sort subexpressions of an expression by containment.
See Also
list, seq, sort
Download Help Document