This data type represents a symmetric binary relation over a set of
elements of type a. Symmetric relations satisfy all laws of the
Undirected type class, including the commutativity of
connect:
connect x y == connect y xThe Show instance lists edge vertices in non-decreasing order:
show (empty :: Relation Int) == "empty"
show (1 :: Relation Int) == "vertex 1"
show (1 + 2 :: Relation Int) == "vertices [1,2]"
show (1 * 2 :: Relation Int) == "edge 1 2"
show (2 * 1 :: Relation Int) == "edge 1 2"
show (1 * 2 * 1 :: Relation Int) == "edges [(1,1),(1,2)]"
show (3 * 2 * 1 :: Relation Int) == "edges [(1,2),(1,3),(2,3)]"
show (1 * 2 + 3 :: Relation Int) == "overlay (vertex 3) (edge 1 2)"The total order on graphs is defined using size-lexicographic comparison:
Compare the number of vertices. In case of a tie, continue.
Compare the sets of vertices. In case of a tie, continue.
Compare the number of edges. In case of a tie, continue.
Compare the sets of edges.
Here are a few examples:
vertex 1 < vertex 2
vertex 3 < edge 1 2
vertex 1 < edge 1 1
edge 1 1 < edge 1 2
edge 1 2 < edge 1 1 + edge 2 2
edge 2 1 < edge 1 3edge 1 2 == edge 2 1Note that the resulting order refines the isSubgraphOf relation and is compatible with overlay and connect operations:
isSubgraphOf x y ==> x <= yempty <= x
x <= x + y
x + y <= x * yInstances13Eq, Num, Ord, Show, IsString, Semigroup, …
Eq a => Eq (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.Symmetric(Ord a, Num a) => Num (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricNote: this does not satisfy the usual ring laws; see Relation for more details.
Ord a => Ord (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.Symmetric(Ord a, Show a) => Show (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricIsString a => IsString (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricOrd a => Semigroup (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricDefined via overlay.
Ord a => Monoid (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricNFData a => NFData (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricOrd a => Graph (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.ClassOrd a => Undirected (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.ClassOrd a => ToGraph (Relation a)Defined in algebraic-graphs-0.8 · Algebra.Graph.Relation.SymmetricDefined via fromSymmetric and the ToGraph instance of Relation.
type Vertex (Relation a) = aDefined in algebraic-graphs-0.8 · Algebra.Graph.Classtype ToVertex (Relation a) = aDefined in algebraic-graphs-0.8 · Algebra.Graph.Relation.Symmetric