PartiallyOrderedSets
ToGraph
Converts a poset into a graph object of the GraphTheory package
Calling Sequence
Parameters
Options
Description
Examples
References
Compatibility
ToGraph(P)
ToGraph(P,gopts,dgopts)
P
-
PartiallyOrderedSet
gopts
(optional) zero or more options specific to the ToGraph command, of the form graded = b, reduction = b, setcoordinates = b where b is a boolean
dgopts
(optional) zero or more options to be passed to the GraphTheory:-DrawGraph command
reduction = truefalse
There are two (potentially) different graphs that this command can generate: the graph where the arrows form the transitive reduction of the ordering of P, and the graph where the arrows form the transitive closure of the ordering. By default, ToGraph returns the transitive reduction graph (the Hasse diagram). When passed the option reduction = false, it returns the transitive closure graph. Passing the option reduction or reduction = true explicitly selects the default transitive reduction graph.
setcoordinates = truefalse
When constructing the transitive reduction graph, Maple will by default compute a suitable layout of the vertices, so that a subsequent call to GraphTheory:-DrawGraph can use that layout. To disable this feature, you can pass the option setcoordinates = false. Passing the option setcoordinates or setcoordinates = true explicitly selects the default of computing the coordinates, but it cannot be passed if computing the transitive closure graph.
graded = truefalse
prefer = low or high
If Maple computes a layout for the graph, the options graded and prefer are used by the PartiallyOrderedSets:-DrawGraph command to fine-tune the layout. They are explained on that command's help page. The options cannot be used if computing the transitive closure graph.
dgopts (not a literal option name)
If passing any extra options not mentioned before (represented by dgopts in the calling sequence above), they are passed on to the GraphTheory:-DrawGraph command.
The command ToGraph(P) returns the graph representation of the partially ordered set P as a graph object of the GraphTheory package. Vertices of the graph are elements of P, and directed edges represent relations between the elements.
Terminology
A partially ordered set, or poset for short, is a pair (P, <=) where P is a set and <= is a partial order on P. The poset (P, <=) defines a directed graph whose vertices are the elements of P and (a,b) is a directed edge whenever a <= b holds. Conversely, a poset can be defined from a directed graph, assuming that the defined binary relation is anti-symmetric, and transitive, and, either reflexive, or irreflexive.
with⁡PartiallyOrderedSets:
leq≔`<=`:
Create a poset from a set and a non-strict partial order
S≔1,2,3,4,5:poset1≔PartiallyOrderedSet⁡S,leq
poset1≔< a poset with 5 elements >
Create the graph representation of this poset
G≔ToGraph⁡poset1
G≔Graph 1: a directed graph with 5 vertices and 4 arcs
Display this graph
GraphTheory:-DrawGraph⁡G
Create a poset from a set and a strict partial order
lneq≔`<`:poset1_1≔PartiallyOrderedSet⁡S,lneq
poset1_1≔< a poset with 5 elements >
G1_1≔ToGraph⁡poset1_1
G1_1≔Graph 2: a directed graph with 5 vertices and 4 arcs
GraphTheory:-DrawGraph⁡G1_1
divisibility≔x,y↦irem⁡y,x=0:T≔3,4,5,6,7,8,9:
poset2≔PartiallyOrderedSet⁡T,divisibility
poset2≔< a poset with 7 elements >
G2≔ToGraph⁡poset2
G2≔Graph 3: a directed graph with 7 vertices and 3 arcs
GraphTheory:-DrawGraph⁡G2
divisibNE≔x,y↦irem⁡y,x=0andy≠x:
poset2_1≔PartiallyOrderedSet⁡T,divisibNE,reflexive=checkfalse
poset2_1≔< a poset with 7 elements >
G2_1≔ToGraph⁡poset2_1
G2_1≔Graph 4: a directed graph with 7 vertices and 3 arcs
GraphTheory:-DrawGraph⁡G2_1
U≔1,2,3:
poset3≔PartiallyOrderedSet⁡U,leq,reflexive=checktrue
poset3≔< a poset with 3 elements >
G3≔ToGraph⁡poset3
G3≔Graph 5: a directed graph with 3 vertices and 2 arcs
GraphTheory:-DrawGraph⁡G3
poset3_1≔PartiallyOrderedSet⁡U,lneq,reflexive=useclosure
poset3_1≔< a poset with 3 elements >
G3_1≔ToGraph⁡poset3_1
G3_1≔Graph 6: a directed graph with 3 vertices and 2 arcs
GraphTheory:-DrawGraph⁡G3_1
X≔4,5,6:poset3_2≔PartiallyOrderedSet⁡X,leq,reflexive=checktrue
poset3_2≔< a poset with 3 elements >
G3_2≔ToGraph⁡poset3_2
G3_2≔Graph 7: a directed graph with 3 vertices and 2 arcs
GraphTheory:-DrawGraph⁡G3_2
Create a poset from a set and an adjacency matrix of a partial order regarded as a directed graph
adjMatrix4≔Matrix⁡1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,0,0,0,1,1,0,0,0,0,1
adjMatrix4≔1111101111001110001100001
poset4≔PartiallyOrderedSet⁡convert⁡S,list,adjMatrix4
poset4≔< a poset with 5 elements >
G4≔ToGraph⁡poset4
G4≔Graph 8: a directed graph with 5 vertices and 4 arcs
GraphTheory:-DrawGraph⁡G4
Create a poset from a set and an adjacency list of a partial order regarded as a directed graph
adjList5≔map2⁡map,`+`,Array⁡1,4,7,2,6,3,4,5,6,7,2
adjList5≔3,6,94,856789
poset5≔PartiallyOrderedSet⁡convert⁡T,list,adjList5
poset5≔< a poset with 7 elements >
G5≔ToGraph⁡poset5
G5≔Graph 9: a directed graph with 7 vertices and 3 arcs
GraphTheory:-DrawGraph⁡G5
Create a poset from a set and a directed graph
G≔GraphTheory:-Graph⁡directed,1,2,3,4,5,6,1,1,1,2,1,3,1,4,1,5,1,6,2,2,2,4,2,6,3,3,3,5,3,6,4,4,4,6,5,5,5,6,6,6
G≔Graph 10: a directed graph with 6 vertices, 11 arcs, and 6 self-loops
poset6≔PartiallyOrderedSet⁡G
poset6≔< a poset with 6 elements >
G6≔ToGraph⁡poset6
G6≔Graph 11: a directed graph with 6 vertices and 6 arcs
GraphTheory:-DrawGraph⁡G6
Create a poset from a set an adjacency matrix of the transitive reduction of a partial order on that set
poset7≔PartiallyOrderedSet⁡convert⁡U,list,1|1|0,0|1|1,0|0|1,input=transitivereduction
poset7≔< a poset with 3 elements >
G7≔ToGraph⁡poset7
G7≔Graph 12: a directed graph with 3 vertices and 2 arcs
GraphTheory:-DrawGraph⁡G7
Create a poset from a set and an adjacency list of the transitive reduction of a partial order on that set
poset8≔PartiallyOrderedSet⁡1,2,3,4,5,6,Array⁡1,2,3,2,4,3,5,4,6,5,6,6,input=transitivereduction
poset8≔< a poset with 6 elements >
G8≔ToGraph⁡poset8
G8≔Graph 13: a directed graph with 6 vertices and 6 arcs
GraphTheory:-DrawGraph⁡G8
Define a polyhedral set and get its dimension
t≔PolyhedralSets:-ExampleSets:-Octahedron⁡
t≔{Coordinates:x1,x2,x3Relations:−x1−x2−x3≤1,−x1−x2+x3≤1,−x1+x2−x3≤1,−x1+x2+x3≤1,x1−x2−x3≤1,x1−x2+x3≤1,x1+x2−x3≤1,x1+x2+x3≤1
d≔PolyhedralSets:-Dimension⁡t
d≔3
Collect the faces of this polyhedral set
t_faces≔seq⁡op⁡PolyhedralSets:-Faces⁡t,dimension=i,i=−0..d:
t_faces≔t_facesunionPolyhedralSets:-ExampleSets:-EmptySet⁡d:
FL≔convert⁡t_faces,list:
Construct the face lattice of that polyhedral set
inclusion := proc(x,y) PolyhedralSets:-`subset`(FL[x],FL[y]) end proc:
polyhedral_poset≔PartiallyOrderedSet⁡seq⁡i,i=1..nops⁡FL,inclusion
polyhedral_poset≔< a poset with 28 elements >
G_POLY≔ToGraph⁡polyhedral_poset
G_POLY≔Graph 14: a directed graph with 28 vertices and 62 arcs
GraphTheory:-DrawGraph⁡G_POLY
M≔Matrix⁡1,1,1,1,1,0,1,1,0,1,0,0,1,0,1,0,0,0,1,1,0,0,0,0,1:
poset9≔PartiallyOrderedSet⁡seq⁡1..5,M
poset9≔< a poset with 5 elements >
G9≔ToGraph⁡poset9
G9≔Graph 15: a directed graph with 5 vertices and 5 arcs
GraphTheory:-DrawGraph⁡G9
Z≔1,2,3,4,5,6,10,12,15,20,30,60
poset10≔PartiallyOrderedSet⁡Z,divisibility
poset10≔< a poset with 12 elements >
Create the graph representation of the transitive closure of this poset
G10_C≔ToGraph⁡poset10,reduction=false
G10_C≔Graph 16: a directed graph with 12 vertices and 42 arcs
GraphTheory:-DrawGraph⁡G10_C
Create the graph representation of the transitive reduction of this poset. If we need the graph structure for the transitive reduction but are not planning to display it, we can skip computing the layout using the option setcoordinates=false.
G10_RNC≔ToGraph⁡poset10,setcoordinates=false
G10_RNC≔Graph 17: a directed graph with 12 vertices and 20 arcs
If we display it anyway, the layout is not particularly insightful.
GraphTheory:-DrawGraph⁡G10_RNC
If we omit the setcoordinates=false option, Maple computes a layout that respects the grading of poset10.
G10_RC≔ToGraph⁡poset10
G10_RC≔Graph 17: a directed graph with 12 vertices and 20 arcs
GraphTheory:-DrawGraph⁡G10_RC
Richard P. Stanley: Enumerative Combinatorics 1. 1997, Cambridge Studies in Advanced Mathematics. Vol. 49. Cambridge University Press.
The PartiallyOrderedSets[ToGraph] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
PartiallyOrderedSets[AdjacencyList]
PartiallyOrderedSets[AreEqual]
PartiallyOrderedSets[AreIsomorphic]
PartiallyOrderedSets[ConnectedComponents]
PartiallyOrderedSets[DrawGraph]
PartiallyOrderedSets[GreatestElement]
PartiallyOrderedSets[GreatestLowerBound]
PartiallyOrderedSets[Height]
PartiallyOrderedSets[IsAntichain]
PartiallyOrderedSets[IsChain]
PartiallyOrderedSets[IsFaceLattice]
PartiallyOrderedSets[IsGraded]
PartiallyOrderedSets[IsLattice]
PartiallyOrderedSets[IsRanked]
PartiallyOrderedSets[LeastElement]
PartiallyOrderedSets[LeastUpperBound]
PartiallyOrderedSets[LessEqual]
PartiallyOrderedSets[MaximalAntichains]
PartiallyOrderedSets[MaximalChains]
PartiallyOrderedSets[MaximalElements]
PartiallyOrderedSets[MinimalElements]
PartiallyOrderedSets[NumberOfElements]
PartiallyOrderedSets[PartiallyOrderedSet]
PartiallyOrderedSets[Rank]
PartiallyOrderedSets[ToGraph]
PartiallyOrderedSets[TransitiveClosure]
PartiallyOrderedSets[TransitiveReduction]
PartiallyOrderedSets[Width]
Download Help Document