Skip to content

Commit cb9b210

Browse files
committed
Go over element_order comment
1 parent 271d990 commit cb9b210

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

pymathics/graph/base.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,16 @@ def __str__(self):
206206
def element_order(self) -> tuple:
207207
"""
208208
Return a value which is used in ordering elements
209-
of an expression. The tuple is ultimately compared lexicographically.
209+
of an expression and Sort[]. The tuple is ultimately compared lexicographically.
210210
"""
211-
# Return the precedence the expression `Image[]`,
212-
# but with a `2` instead of `1` in the 5th position,
213-
# and adding two extra fields: the length in the 3rd position,
214-
# and a hash in the 6th place.
211+
# Return the precedence similar to the key for an `Image[]`
212+
# object, but with a `2` instead of `1` in the 5th position,
213+
#
214+
# Graphs with fewer vertices in a graph should appear before
215+
# nodes with more vertices. This property is captured by the
216+
# 3rd position, of the order tuple. A hash of the object is put
217+
# last for two graphs are structurally the same but different, so that
218+
# the same graph object will appear consecutively in a Sort[].
215219
return (
216220
GRAPH_EXPRESSION_SORT_KEY,
217221
SymbolGraph,
@@ -395,12 +399,16 @@ def is_multigraph(self):
395399
def element_order(self) -> tuple:
396400
"""
397401
Return a value which is used in ordering elements
398-
of an expression. The tuple is ultimately compared lexicographically.
402+
of an expression and Sort[]. The tuple is ultimately compared lexicographically.
399403
"""
400-
# Return the precedence the expression `Image[]`,
401-
# but with a `2` instead of `1` in the 5th position,
402-
# and adding two extra fields: the length in the 3rd position,
403-
# and a hash in the 6th place.
404+
# Return the precedence similar to the key for an `Image[]`
405+
# object, but with a `2` instead of `1` in the 5th position,
406+
#
407+
# Graphs with fewer vertices in a graph should appear before
408+
# nodes with more vertices. This property is captured by the
409+
# 3rd position, of the order tuple. A hash of the object is put
410+
# last for two graphs are structurally the same but different, so that
411+
# the same graph object will appear consecutively in a Sort[].
404412
return (
405413
GRAPH_EXPRESSION_SORT_KEY,
406414
SymbolGraph,

0 commit comments

Comments
 (0)