PartiallyOrderedSets/ToGraph - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : PartiallyOrderedSets/ToGraph

PartiallyOrderedSets

  

ToGraph

  

Converts a poset into a graph object of the GraphTheory package

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

ToGraph(P)

ToGraph(P,gopts,dgopts)

Parameters

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

Options

• 

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.

Description

• 

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.

Examples

> 

with⁡PartiallyOrderedSets&colon;

> 

leq≔`<=`&colon;

Create a poset from a set and a non-strict partial order

> 

S≔1&comma;2&comma;3&comma;4&comma;5&colon;poset1≔PartiallyOrderedSet⁡S&comma;leq

poset1≔< a poset with 5 elements >

(1)

Create the graph representation of this poset

> 

G≔ToGraph⁡poset1

G≔Graph 1: a directed graph with 5 vertices and 4 arcs

(2)

Display this graph

> 

GraphTheory:-DrawGraph⁡G

Create a poset from a set and a strict partial order

> 

lneq≔`<`&colon;poset1_1≔PartiallyOrderedSet⁡S&comma;lneq

poset1_1≔< a poset with 5 elements >

(3)

Create the graph representation of this poset

> 

G1_1≔ToGraph⁡poset1_1

G1_1≔Graph 2: a directed graph with 5 vertices and 4 arcs

(4)

Display this graph

> 

GraphTheory:-DrawGraph⁡G1_1

Create a poset from a set and a non-strict partial order

> 

divisibility≔x&comma;y↦irem⁡y&comma;x=0&colon;T≔3&comma;4&comma;5&comma;6&comma;7&comma;8&comma;9&colon;

> 

poset2≔PartiallyOrderedSet⁡T&comma;divisibility

poset2≔< a poset with 7 elements >

(5)

Create the graph representation of this poset

> 

G2≔ToGraph⁡poset2

G2≔Graph 3: a directed graph with 7 vertices and 3 arcs

(6)

Display this graph

> 

GraphTheory:-DrawGraph⁡G2

Create a poset from a set and a strict partial order

> 

divisibNE≔x&comma;y↦irem⁡y&comma;x=0andy≠x&colon;

> 

poset2_1≔PartiallyOrderedSet⁡T&comma;divisibNE&comma;reflexive=checkfalse

poset2_1≔< a poset with 7 elements >

(7)

Create the graph representation of this poset

> 

G2_1≔ToGraph⁡poset2_1

G2_1≔Graph 4: a directed graph with 7 vertices and 3 arcs

(8)

Display this graph

> 

GraphTheory:-DrawGraph⁡G2_1

Create a poset from a set and a non-strict partial order

> 

U≔1&comma;2&comma;3&colon;

> 

poset3≔PartiallyOrderedSet⁡U&comma;leq&comma;reflexive=checktrue

poset3≔< a poset with 3 elements >

(9)

Create the graph representation of this poset

> 

G3≔ToGraph⁡poset3

G3≔Graph 5: a directed graph with 3 vertices and 2 arcs

(10)

Display this graph

> 

GraphTheory:-DrawGraph⁡G3

Create a poset from a set and a strict partial order

> 

poset3_1≔PartiallyOrderedSet⁡U&comma;lneq&comma;reflexive=useclosure

poset3_1≔< a poset with 3 elements >

(11)

Create the graph representation of this poset

> 

G3_1≔ToGraph⁡poset3_1

G3_1≔Graph 6: a directed graph with 3 vertices and 2 arcs

(12)

Display this graph

> 

GraphTheory:-DrawGraph⁡G3_1

Create a poset from a set and a non-strict partial order

> 

X≔4&comma;5&comma;6&colon;poset3_2≔PartiallyOrderedSet⁡X&comma;leq&comma;reflexive=checktrue

poset3_2≔< a poset with 3 elements >

(13)

Create the graph representation of this poset

> 

G3_2≔ToGraph⁡poset3_2

G3_2≔Graph 7: a directed graph with 3 vertices and 2 arcs

(14)

Display this graph

> 

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&comma;1&comma;1&comma;1&comma;1&comma;0&comma;1&comma;1&comma;1&comma;1&comma;0&comma;0&comma;1&comma;1&comma;1&comma;0&comma;0&comma;0&comma;1&comma;1&comma;0&comma;0&comma;0&comma;0&comma;1

adjMatrix4≔1111101111001110001100001

(15)
> 

poset4≔PartiallyOrderedSet⁡convert⁡S&comma;list&comma;adjMatrix4

poset4≔< a poset with 5 elements >

(16)

Create the graph representation of this poset

> 

G4≔ToGraph⁡poset4

G4≔Graph 8: a directed graph with 5 vertices and 4 arcs

(17)

Display this graph

> 

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&comma;`+`&comma;Array⁡1&comma;4&comma;7&comma;2&comma;6&comma;3&comma;4&comma;5&comma;6&comma;7&comma;2

adjList5≔3&comma;6&comma;94&comma;856789

(18)
> 

poset5≔PartiallyOrderedSet⁡convert⁡T&comma;list&comma;adjList5

poset5≔< a poset with 7 elements >

(19)

Create the graph representation of this poset

> 

G5≔ToGraph⁡poset5

G5≔Graph 9: a directed graph with 7 vertices and 3 arcs

(20)

Display this graph

> 

GraphTheory:-DrawGraph⁡G5

Create a poset from a set and a directed graph

> 

G≔GraphTheory:-Graph⁡directed&comma;1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;1&comma;1&comma;1&comma;2&comma;1&comma;3&comma;1&comma;4&comma;1&comma;5&comma;1&comma;6&comma;2&comma;2&comma;2&comma;4&comma;2&comma;6&comma;3&comma;3&comma;3&comma;5&comma;3&comma;6&comma;4&comma;4&comma;4&comma;6&comma;5&comma;5&comma;5&comma;6&comma;6&comma;6

G≔Graph 10: a directed graph with 6 vertices, 11 arcs, and 6 self-loops

(21)
> 

poset6≔PartiallyOrderedSet⁡G

poset6≔< a poset with 6 elements >

(22)

Create the graph representation of this poset

> 

G6≔ToGraph⁡poset6

G6≔Graph 11: a directed graph with 6 vertices and 6 arcs

(23)

Display this graph

> 

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&comma;list&comma;1|1|0&comma;0|1|1&comma;0|0|1&comma;input=transitivereduction

poset7≔< a poset with 3 elements >

(24)

Create the graph representation of this poset

> 

G7≔ToGraph⁡poset7

G7≔Graph 12: a directed graph with 3 vertices and 2 arcs

(25)

Display this graph

> 

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&comma;2&comma;3&comma;4&comma;5&comma;6&comma;Array⁡1&comma;2&comma;3&comma;2&comma;4&comma;3&comma;5&comma;4&comma;6&comma;5&comma;6&comma;6&comma;input=transitivereduction

poset8≔< a poset with 6 elements >

(26)

Create the graph representation of this poset

> 

G8≔ToGraph⁡poset8

G8≔Graph 13: a directed graph with 6 vertices and 6 arcs

(27)

Display this graph

> 

GraphTheory:-DrawGraph⁡G8

Define a polyhedral set and get its dimension

> 

t≔PolyhedralSets:-ExampleSets:-Octahedron⁡

t≔&lcub;Coordinates&colon;x1&comma;x2&comma;x3Relations&colon;−x1−x2−x3≤1&comma;−x1−x2+x3≤1&comma;−x1+x2−x3≤1&comma;−x1+x2+x3≤1&comma;x1−x2−x3≤1&comma;x1−x2+x3≤1&comma;x1+x2−x3≤1&comma;x1+x2+x3≤1

(28)
> 

d≔PolyhedralSets:-Dimension⁡t

d≔3

(29)

Collect the faces of this polyhedral set

> 

t_faces≔seq⁡op⁡PolyhedralSets:-Faces⁡t&comma;dimension=i&comma;i=−0..d&colon;

> 

t_faces≔t_facesunionPolyhedralSets:-ExampleSets:-EmptySet⁡d&colon;

> 

FL≔convert⁡t_faces&comma;list&colon;

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&comma;i=1..nops⁡FL&comma;inclusion

polyhedral_poset≔< a poset with 28 elements >

(30)

Create the graph representation of this poset

> 

G_POLY≔ToGraph⁡polyhedral_poset

G_POLY≔Graph 14: a directed graph with 28 vertices and 62 arcs

(31)

Display this graph

> 

GraphTheory:-DrawGraph⁡G_POLY

Create a poset from a set and an adjacency matrix of a partial order regarded as a directed graph

> 

M≔Matrix⁡1&comma;1&comma;1&comma;1&comma;1&comma;0&comma;1&comma;1&comma;0&comma;1&comma;0&comma;0&comma;1&comma;0&comma;1&comma;0&comma;0&comma;0&comma;1&comma;1&comma;0&comma;0&comma;0&comma;0&comma;1&colon;

> 

poset9≔PartiallyOrderedSet⁡seq⁡1..5&comma;M

poset9≔< a poset with 5 elements >

(32)

Create the graph representation of this poset

> 

G9≔ToGraph⁡poset9

G9≔Graph 15: a directed graph with 5 vertices and 5 arcs

(33)

Display this graph

> 

GraphTheory:-DrawGraph⁡G9

 

Create a poset from a set and a non-strict partial order

> 

Z≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

Z≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

(34)
> 

poset10≔PartiallyOrderedSet⁡Z&comma;divisibility

poset10≔< a poset with 12 elements >

(35)

Create the graph representation of the transitive closure of this poset

> 

G10_C≔ToGraph⁡poset10&comma;reduction=false

G10_C≔Graph 16: a directed graph with 12 vertices and 42 arcs

(36)

Display this graph

> 

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&comma;setcoordinates=false

G10_RNC≔Graph 17: a directed graph with 12 vertices and 20 arcs

(37)

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

(38)
> 

GraphTheory:-DrawGraph⁡G10_RC

References

  

Richard P. Stanley: Enumerative Combinatorics 1. 1997, Cambridge Studies in Advanced Mathematics. Vol. 49. Cambridge University Press.

Compatibility

• 

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]