core.figure_generation_files package
Submodules
core.figure_generation_files.pathmarker module
- class core.figure_generation_files.pathmarker.PathMarker(graph, pos, default_edges, default_nodes)[source]
Bases:
object
A class that represents a path marker for a graph. This is used as a class since we want to keep track of one instance of a graph. This instance is used to keep track of the marked nodes and edges in the graph. Note we can mark nodes with left-click and right-click. Marked nodes and edges are drawn in royalblue color, while right-click marked nodes are drawn in darkturquoise color.
Note
Both nodes and edges can be marked with left-click.
Only nodes can be right-click marked. Edges cannot!
- graph
The networkx graph object.
- Type:
nx.Graph
- pos
The position of the nodes in the graph. The keys are the nodes and the values are the positions.
- Type:
dict
- marked_nodes
A set of marked nodes. Starts empty.
- Type:
set
- right_marked_nodes
A set of right-click marked nodes. Starts empty.
- Type:
set
- marked_edges
A set of marked edges. Starts empty.
- Type:
set
- edge_colors
A list of colors for the edges. Is black by default. If a Lehmer path is highlighted, the edge colors are changed to red.
- Type:
list
- node_colors
A list of colors for the nodes. Is lightblue by default. If a Lehmer path is highlighted, the graph has the following colors:
Orange for the spur bases
Olive for the spur tips
Deeppink for the other visited nodes
Lightblue for the unvisited nodes
- Type:
list
- mark_node(node)[source]
Marks a node.
- Parameters:
node (str) – The node to be marked.
- Return type:
None
- Returns:
None
- right_mark_node(node)[source]
Marks a node with a right-click.
- Parameters:
node (str) – The node to be right-click marked.
- Return type:
None
- Returns:
None
- un_right_mark_node(node)[source]
Unmarks a right-click marked node.
- Parameters:
node (str) – The node to be unmarked.
- Return type:
None
- Returns:
None
- unmark_node(node)[source]
Unmarks a node.
- Parameters:
node (str) – The node to be unmarked.
- Return type:
None
- Returns:
None
- toggle_node(node)[source]
Toggles the marking of a node.
- Parameters:
node (str) – The node to be toggled.
- Return type:
None
- Returns:
None
- toggle_right_mark_node(node)[source]
Toggles the right-click marking of a node. If the node is already right-click marked, it will be unmarked and vice versa.
- Parameters:
node (str) – The node to be toggled.
- Return type:
None
- Returns:
None
- mark_edge(edge)[source]
Marks an edge.
- Parameters:
edge (tuple[str, str]) – The edge to be marked.
- Return type:
None
- Returns:
None
- unmark_edge(edge)[source]
Unmarks an edge.
- Parameters:
edge (tuple[str, str]) – The edge to be unmarked.
- Return type:
None
- Returns:
None
- toggle_edge(edge)[source]
Toggles the marking of an edge. If the edge is already marked, it will be unmarked and vice versa.
- Parameters:
edge (tuple[str, str]) – The edge to be toggled.
- Return type:
None
- Returns:
None
- reset_colors()[source]
Clears the sets of marked nodes and edges. This is to reset the colors of the graph.
- Return type:
None
- Returns:
None
- update_plot(nx, plt_instance)[source]
Updates the plot with the marked nodes and edges. Draws it in the matplotlib pyplot instance. Marked nodes and edges are drawn in royalblue color. For right-click marked nodes, they are drawn in darkturquoise color.
- Parameters:
nx (nx.Graph) – The networkx graph object.
plt_instance (plt) – The matplotlib pyplot instance.
- Return type:
None
- Returns:
None
core.figure_generation_files.rivertz module
- core.figure_generation_files.rivertz.swap_elements(a_list, i, j)[source]
Swaps the elements at positions i and j in the given list.
- Parameters:
a_list (list) – The list in which the elements will be swapped.
i (int) – The index of the first element to be swapped.
j (int) – The index of the second element to be swapped.
- Returns:
(the list is modified in place)
- Return type:
None
- class core.figure_generation_files.rivertz.SetPerm(multiplicity)[source]
Bases:
Iterator
,ABC
This file is directly copied from the original source code of the article: “Multiset permutation generation by transpositions” by Rivertz The original source code is available at: https://doi.org/10.48550/arXiv.2309.11781
Therefore we also did not test or document this file as it is not part of our codebase.
References
Hans Jakob Rivertz. Multiset permutation generation by transpositions. 9 2023
core.figure_generation_files.verhoeffCycleCoverPaths module
- core.figure_generation_files.verhoeffCycleCoverPaths.fig11(ax, even_int)[source]
Generate and plot Figure 11 from Verhoeff’s paper (see References). The figure displays a path between c and d:
c1 = 12 0^k_0 1
d1 = 0 21 0^{k_0-1} 1
where k_0 is an even integer (even_int). The path is highlighted in blue and important nodes are marked.
- Parameters:
ax (Axes) – The matplotlib Axes object to plot the figure on.
even_int (int) – An even integer value.
- Returns:
Works in place to plot the figure on the given ax.
- Return type:
None
References
Tom Verhoeff. The spurs of D. H. Lehmer: Hamiltonian paths in neighbor-swap graphs of permutations. Designs, Codes, and Cryptography, 84(1-2):295-310, 7 2017.
- core.figure_generation_files.verhoeffCycleCoverPaths.fig12(ax, even_int)[source]
Generate and plot Figure 12 from Verhoeff’s paper (see References). The figure displays a path between a and b:
a0 = 12 0^{k_0-1} 1 0
b0 = 0 21 0^{k_0-2} 1 0
where k_0 is an even integer (even_int). The path is highlighted in blue and important nodes are marked.
- Parameters:
ax (Axes) – The matplotlib Axes object to plot the figure on.
even_int (int) – An even integer value.
- Returns:
Works in place to plot the figure on the given ax.
- Return type:
None
References
Tom Verhoeff. The spurs of D. H. Lehmer: Hamiltonian paths in neighbor-swap graphs of permutations. Designs, Codes, and Cryptography, 84(1-2):295-310, 7 2017.
- core.figure_generation_files.verhoeffCycleCoverPaths.fig12_e_f(ax, even_int)[source]
Generate and plot Figure 12 from Verhoeff’s paper (see References). The figure displays a path between e and f:
e0 = 1 02 0^{k_0-2} 1 0
f0 = 0 12 0^{k_0-2} 1 0
where k_0 is an even integer (even_int). The path is highlighted in blue and important nodes are marked.
- Parameters:
ax (Axes) – The matplotlib Axes object to plot the figure on.
even_int (int) – An even integer value.
- Returns:
Works in place to plot the figure on the given ax.
- Return type:
None
References
Tom Verhoeff. The spurs of D. H. Lehmer: Hamiltonian paths in neighbor-swap graphs of permutations. Designs, Codes, and Cryptography, 84(1-2):295-310, 7 2017.
- core.figure_generation_files.verhoeffCycleCoverPaths.combined_figure(even_int, save=False)[source]
Generate and plot both Figure 11 and Figure 12 from Verhoeff’s paper (see References) in a single plot. The figures display paths between c and d and between a and b respectively. The paths are highlighted in blue and important nodes are marked.
- Parameters:
even_int (int) – An even integer value.
save (bool, optional) – Save the image in the ./out directory.
- Returns:
Works in place to plot the figure.
- Return type:
None
References
Tom Verhoeff. The spurs of D. H. Lehmer: Hamiltonian paths in neighbor-swap graphs of permutations. Designs, Codes, and Cryptography, 84(1-2):295-310, 7 2017.
- core.figure_generation_files.verhoeffCycleCoverPaths.plot_individual_figures(even_int, save=False, cycle=False)[source]
Generate and plot Figure 11 and Figure 12 from Verhoeff’s paper (see References) in separate plots. The figures display paths between c and d and between a and b respectively. The paths are highlighted in blue and important nodes are marked. If save is enabled, the images are saved in the ./out directory. If not, the figures are displayed.
- Parameters:
even_int (int) – An even integer value, the number of 0s in the signature.
save (bool, optional) – Save the images in the ./out directory. Defaults to False which displays the figures.
cycle (bool, optional) – Generate a cycle instead of a path. Default is False.
- Returns:
Works in place to plot the figures.
- Return type:
None
References
Tom Verhoeff. The spurs of D. H. Lehmer: Hamiltonian paths in neighbor-swap graphs of permutations. Designs, Codes, and Cryptography, 84(1-2):295-310, 7 2017.