({{, x<->y or x<->y
represents a two-way rule expressing exchange or correspondence of x and y.}})

OpenersNotesSection(Spacer1)Details

Two-way rules are very general constructs that can represent exchange, equivalence, correspondence and other bidirectional relations between expressions.

The character <-> can be entered as ∖[TwoWayRule].

In (RefLink[StandardForm, paclet:ref/StandardForm]), (RefLink[TwoWayRule, paclet:ref/TwoWayRule]) is printed using <->.

(RefLink[Transpose, paclet:ref/Transpose])[array,n<->m] transposes levels n and m of the array, without changing other levels.

(RefLink[TwoWayRule, paclet:ref/TwoWayRule])[a,b] is equivalent to (RefLink[UndirectedEdge, paclet:ref/UndirectedEdge])[a,b] in (RefLink[Graph, paclet:ref/Graph]) constructors.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Exchange levels 2 and 3 of an array of depth 3 using (RefLink[TwoWayRule, paclet:ref/TwoWayRule]) to express a permutation:

Transpose[{{{{1,2},{3,4}},{{5,6},{7,8}}}},2<->3]

Input undirected edges in a graph using (RefLink[TwoWayRule, paclet:ref/TwoWayRule]):

Graph[{a<->b,b<->c,c<->a}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Rule, paclet:ref/Rule])  ▪  (RefLink[UndirectedEdge, paclet:ref/UndirectedEdge])  ▪  (RefLink[Cycles, paclet:ref/Cycles])  ▪  (RefLink[Equal, paclet:ref/Equal])  ▪  (RefLink[Equivalent, paclet:ref/Equivalent])  ▪  (RefLink[Graph, paclet:ref/Graph])  ▪  (RefLink[Transpose, paclet:ref/Transpose])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Rules & Patterns, paclet:guide/RulesAndPatterns])}, {▪(RefLinkPlain[Rules, paclet:guide/Rules])}, {▪(RefLinkPlain[Language Overview, paclet:guide/LanguageOverview])}})}})