Update app.py
Browse files
app.py
CHANGED
|
@@ -605,7 +605,7 @@ app.layout = html.Div(
|
|
| 605 |
html.Div(
|
| 606 |
style={"display": "flex", "gap": "8px", "alignItems": "center", "marginBottom": "8px"},
|
| 607 |
children=[
|
| 608 |
-
html.Button("Flip subpath
|
| 609 |
style={"background": "#2563EB", "color": "white"}),
|
| 610 |
dcc.Input(
|
| 611 |
id="subpath_dim",
|
|
@@ -834,16 +834,16 @@ def update_path(clickData,
|
|
| 834 |
return path, {"active": False, "start_idx": None, "end_idx": None}
|
| 835 |
|
| 836 |
# subpath is path[s:e+1] = (v1,...,vk)
|
| 837 |
-
#
|
| 838 |
-
#
|
| 839 |
-
head = path[:s + 1]
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
new_path = head + flipped_tail + rest
|
| 844 |
|
| 845 |
return new_path, {"active": False, "start_idx": None, "end_idx": None}
|
| 846 |
|
|
|
|
| 847 |
# 7) Figure clicks
|
| 848 |
if trigger == "fig" and clickData and clickData.get("points"):
|
| 849 |
p = clickData["points"][0]
|
|
|
|
| 605 |
html.Div(
|
| 606 |
style={"display": "flex", "gap": "8px", "alignItems": "center", "marginBottom": "8px"},
|
| 607 |
children=[
|
| 608 |
+
html.Button("Flip subpath", id="btn_flip_subpath", n_clicks=0,
|
| 609 |
style={"background": "#2563EB", "color": "white"}),
|
| 610 |
dcc.Input(
|
| 611 |
id="subpath_dim",
|
|
|
|
| 834 |
return path, {"active": False, "start_idx": None, "end_idx": None}
|
| 835 |
|
| 836 |
# subpath is path[s:e+1] = (v1,...,vk)
|
| 837 |
+
# desired: keep prefix (..., v1), keep suffix (vk, ...),
|
| 838 |
+
# and insert flipped(v1..vk) between them.
|
| 839 |
+
head = path[:s + 1] # includes v1
|
| 840 |
+
flipped_subpath = [flip_dim_vertex(v, i) for v in path[s:e + 1]]
|
| 841 |
+
rest = path[e:] # starts at vk
|
| 842 |
+
new_path = head + flipped_subpath + rest
|
|
|
|
| 843 |
|
| 844 |
return new_path, {"active": False, "start_idx": None, "end_idx": None}
|
| 845 |
|
| 846 |
+
|
| 847 |
# 7) Figure clicks
|
| 848 |
if trigger == "fig" and clickData and clickData.get("points"):
|
| 849 |
p = clickData["points"][0]
|