diff --git a/conan/cli/formatters/graph/graph.py b/conan/cli/formatters/graph/graph.py
index ea3d692d172..08711a47ac4 100644
--- a/conan/cli/formatters/graph/graph.py
+++ b/conan/cli/formatters/graph/graph.py
@@ -54,7 +54,8 @@ def data(self):
class _Grapher(object):
def __init__(self, deps_graph):
self._deps_graph = deps_graph
- self.nodes, self.edges = self._build_graph()
+ self.node_map, self.edges = self._build_graph()
+ self.nodes = self.node_map.values()
def _build_graph(self):
graph_nodes = self._deps_graph.by_levels()
@@ -73,7 +74,7 @@ def _build_graph(self):
dst = _node_map[node_to]
edges.append((src, dst))
- return _node_map.values(), edges
+ return _node_map, edges
@staticmethod
def binary_color(node):
diff --git a/conan/cli/formatters/graph/info_graph_html.py b/conan/cli/formatters/graph/info_graph_html.py
index 394a7ceca2b..491750bc796 100644
--- a/conan/cli/formatters/graph/info_graph_html.py
+++ b/conan/cli/formatters/graph/info_graph_html.py
@@ -56,7 +56,7 @@
font: { color: "{% if highlight_node %}white{% else %}black{% endif %}" },
fulllabel: '
{{ node.label }}
' +
'' +
- ' - id: {{ node.package_id }}
' +
+ ' - package id: {{ node.package_id }}
' +
{%- for key, value in node.data().items() %}
{%- if value %}
{%- if key in ['url', 'homepage'] %}
@@ -92,22 +92,22 @@
{% if error["context"].node.id is not none %}
// Add edge from node that introduces the conflict to the new error node
- edges.push({from: {{ error["context"].node.id }},
+ edges.push({from: {{ graph.node_map[error["context"].node].id }},
to: "{{ error["type"] }}",
color: "red",
- dashes: true,
+ dashes: false,
title: "Conflict",
physics: false,
color: "red",
- arrows: "to;from"})
+ arrows: "to"})
{% endif %}
{% if error["context"].prev_node is none and error["context"].base_previous.id is not none %}
// Add edge from base node to the new error node
- edges.push({from: {{ error["context"].base_previous.id }},
+ edges.push({from: {{ graph.node_map[error["context"].base_previous].id }},
to: "{{ error["type"] }}",
color: "red",
- dashes: true,
+ dashes: false,
title: "Conflict",
physics: false,
color: "red",
@@ -116,13 +116,13 @@
{% if error["context"].prev_node is not none and error["context"].prev_node.id is not none %}
// Add edge from previous node that already had conflicting dependency
- edges.push({from: {{ error["context"].prev_node.id }},
+ edges.push({from: {{ graph.node_map[error["context"].prev_node].id }},
to: "{{ error["type"] }}",
color: "red",
dashes: true,
title: "Conflict",
physics: false,
- color: "red",
+ color: "gray",
arrows: "to;from"})
{% endif %}
diff --git a/conans/test/integration/command/info/test_graph_info_graphical.py b/conans/test/integration/command/info/test_graph_info_graphical.py
index be4e5ff635a..2d315f28e96 100644
--- a/conans/test/integration/command/info/test_graph_info_graphical.py
+++ b/conans/test/integration/command/info/test_graph_info_graphical.py
@@ -201,6 +201,9 @@ def test_graph_info_html_output():
assert "// Add edge from base node to the new error node" not in tc.out
assert "// Add edge from previous node that already had conflicting dependency" in tc.out
+ # Ensure mapping is preserved, ui is node id 3 before ordering, but 2 after
+ assert "id: 2,\n label: 'ui/1.0'" in tc.out
+
tc.run("graph info openimageio/ --format=html", assert_error=True)
assert "// Add error conflict node" in tc.out
assert "// Add edge from node that introduces the conflict to the new error node" in tc.out