Skip to content

Commit cb2bd43

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

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pymathics/graph/base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,16 @@ def is_multigraph(self):
395395
def element_order(self) -> tuple:
396396
"""
397397
Return a value which is used in ordering elements
398-
of an expression. The tuple is ultimately compared lexicographically.
398+
of an expression and Sort[]. The tuple is ultimately compared lexicographically.
399399
"""
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.
400+
# Return the precedence similar to the key for an `Image[]`
401+
# object, but with a `2` instead of `1` in the 5th position,
402+
#
403+
# Graphs with fewer vertices in a graph should appear before
404+
# nodes with more vertices. This property is captured by the
405+
# 3rd position, of the order tuple. A hash of the object is put
406+
# last for two graphs are structurally the same but different, so that
407+
# the same graph object will appear consecutively in a Sort[].
404408
return (
405409
GRAPH_EXPRESSION_SORT_KEY,
406410
SymbolGraph,

0 commit comments

Comments
 (0)