diff --git a/nipype/pipeline/engine/base.py b/nipype/pipeline/engine/base.py
index 9d0bc3c69..7f7afd392 100644
--- a/nipype/pipeline/engine/base.py
+++ b/nipype/pipeline/engine/base.py
@@ -36,11 +36,11 @@ class EngineBase(object):
 
         """
         self._hierarchy = None
-        self._name = None
+        self.name = name
+        self._id = self.name # for compatibility with node expansion using iterables
 
         self.base_dir = base_dir
         self.config = deepcopy(config._sections)
-        self.name = name
 
     @property
     def name(self):
@@ -66,6 +66,14 @@ class EngineBase(object):
     def outputs(self):
         raise NotImplementedError
 
+    @property
+    def itername(self):
+        """Name for expanded iterable"""
+        itername = self._id
+        if self._hierarchy:
+            itername = '%s.%s' % (self._hierarchy, self._id)
+        return itername
+
     def clone(self, name):
         """Clone an EngineBase object
 
@@ -95,6 +103,9 @@ class EngineBase(object):
     def __str__(self):
         return self.fullname
 
+    def __repr__(self):
+        return self.itername
+
     def save(self, filename=None):
         if filename is None:
             filename = 'temp.pklz'
diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py
index 5ac9e72fa..af93fd140 100644
--- a/nipype/pipeline/engine/nodes.py
+++ b/nipype/pipeline/engine/nodes.py
@@ -159,7 +159,6 @@ class Node(EngineBase):
         self._got_inputs = False
         self._originputs = None
         self._output_dir = None
-        self._id = self.name  # for compatibility with node expansion using iterables
 
         self.iterables = iterables
         self.synchronize = synchronize
@@ -249,14 +248,6 @@ class Node(EngineBase):
         if hasattr(self._interface.inputs, 'num_threads'):
             self._interface.inputs.num_threads = self._n_procs
 
-    @property
-    def itername(self):
-        """Name for expanded iterable"""
-        itername = self._id
-        if self._hierarchy:
-            itername = '%s.%s' % (self._hierarchy, self._id)
-        return itername
-
     def output_dir(self):
         """Return the location of the output directory for the node"""
         # Output dir is cached
diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py
index 4ec36afe6..0bb5351ad 100644
--- a/nipype/pipeline/engine/utils.py
+++ b/nipype/pipeline/engine/utils.py
@@ -507,7 +507,7 @@ def _write_detailed_dot(graph, dotfilename):
     # write nodes
     edges = []
     for n in nx.topological_sort(graph):
-        nodename = str(n)
+        nodename = n.itername
         inports = []
         for u, v, d in graph.in_edges(nbunch=n, data=True):
             for cd in d['connect']:
@@ -519,8 +519,8 @@ def _write_detailed_dot(graph, dotfilename):
                 ipstrip = 'in%s' % _replacefunk(inport)
                 opstrip = 'out%s' % _replacefunk(outport)
                 edges.append(
-                    '%s:%s:e -> %s:%s:w;' % (str(u).replace('.', ''), opstrip,
-                                             str(v).replace('.', ''), ipstrip))
+                    '%s:%s:e -> %s:%s:w;' % (u.itername.replace('.', ''), opstrip,
+                                             v.itername.replace('.', ''), ipstrip))
                 if inport not in inports:
                     inports.append(inport)
         inputstr = ['{IN'] + [

incorrect detailed graphs being generated
### Summary

the detailed graph is not listing names of nodes appropriately resulting in incorrect graphs.

scroll down to see the multiple arrows containing nodes in the figures of the following notebook.
https://miykael.github.io/nipype_tutorial/notebooks/introduction_quickstart.html

an example here:

![image](https://user-images.githubusercontent.com/184063/43534422-50e73862-9585-11e8-83d9-697675db63e8.png)

i suspect this has something to do with how `__repr__` and `__str__` are being used. 

@oesteban, @effigies  - any quick ideas before i look into the code?

### Actual behavior

### Expected behavior

should have printed the old style with multiple nodes. 

see cell 14 in this notebook:
https://github.com/ReproNim/reproducible-imaging/blob/master/notebooks/introductory_dataflows.ipynb

### How to replicate the behavior

run the current quickstart notebook in @miykael binder repo.


diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py
index 151849241..44afbb2e2 100644
--- a/nipype/pipeline/engine/tests/test_engine.py
+++ b/nipype/pipeline/engine/tests/test_engine.py
@@ -441,6 +441,7 @@ def test_write_graph_runs(tmpdir):
 
             assert os.path.exists('graph.dot') or os.path.exists(
                 'graph_detailed.dot')
+       
             try:
                 os.remove('graph.dot')
             except OSError:
@@ -484,6 +485,164 @@ def test_deep_nested_write_graph_runs(tmpdir):
                 pass
 
 
+# examples of dot files used in the following test
+dotfile_orig = ['strict digraph  {\n',
+                '"mod1 (engine)";\n',
+                '"mod2 (engine)";\n',
+                '"mod1 (engine)" -> "mod2 (engine)";\n',
+                '}\n']
+
+dotfile_detailed_orig = ['digraph structs {\n',
+                         'node [shape=record];\n',
+                         'pipemod1 [label="{IN}|{ mod1 | engine |  }|{OUT|<outoutput1> output1}"];\n',
+                         'pipemod2 [label="{IN|<ininput1> input1}|{ mod2 | engine |  }|{OUT}"];\n',
+                         'pipemod1:outoutput1:e -> pipemod2:ininput1:w;\n',
+                         '}']
+
+
+dotfile_hierarchical = ['digraph pipe{\n',
+                        '  label="pipe";\n',
+                        '  pipe_mod1[label="mod1 (engine)"];\n',
+                        '  pipe_mod2[label="mod2 (engine)"];\n',
+                        '  pipe_mod1 -> pipe_mod2;\n',
+                        '}']
+
+dotfile_colored = ['digraph pipe{\n',
+                   '  label="pipe";\n',
+                   '  pipe_mod1[label="mod1 (engine)", style=filled, fillcolor="#FFFFC8"];\n',
+                   '  pipe_mod2[label="mod2 (engine)", style=filled, fillcolor="#FFFFC8"];\n',
+                   '  pipe_mod1 -> pipe_mod2;\n',
+                   '}']
+
+dotfiles = {
+    "orig": dotfile_orig,
+    "flat": dotfile_orig,
+    "exec": dotfile_orig,
+    "hierarchical": dotfile_hierarchical,
+    "colored": dotfile_colored
+    }
+
+@pytest.mark.parametrize("simple", [True, False])
+@pytest.mark.parametrize("graph_type", ['orig', 'flat', 'exec', 'hierarchical', 'colored'])
+def test_write_graph_dotfile(tmpdir, graph_type, simple):
+    """ checking dot files for a workflow without iterables"""
+    tmpdir.chdir()
+
+    pipe = pe.Workflow(name='pipe')
+    mod1 = pe.Node(interface=EngineTestInterface(), name='mod1')
+    mod2 = pe.Node(interface=EngineTestInterface(), name='mod2')
+    pipe.connect([(mod1, mod2, [('output1', 'input1')])])
+    pipe.write_graph(
+        graph2use=graph_type, simple_form=simple, format='dot')
+
+    with open("graph.dot") as f:
+        graph_str = f.read()
+
+    if simple:
+        for line in dotfiles[graph_type]:
+            assert line in graph_str
+    else:
+        # if simple=False graph.dot uses longer names
+        for line in dotfiles[graph_type]:
+            if graph_type in ["hierarchical", "colored"]:
+                assert line.replace("mod1 (engine)", "mod1.EngineTestInterface.engine").replace(
+                    "mod2 (engine)", "mod2.EngineTestInterface.engine") in graph_str
+            else:
+                assert line.replace(
+                    "mod1 (engine)", "pipe.mod1.EngineTestInterface.engine").replace(
+                    "mod2 (engine)", "pipe.mod2.EngineTestInterface.engine") in graph_str
+
+    # graph_detailed is the same for orig, flat, exec (if no iterables)
+    # graph_detailed is not created for hierachical or colored
+    if graph_type not in ["hierarchical", "colored"]:
+        with open("graph_detailed.dot") as f:
+            graph_str = f.read()
+        for line in dotfile_detailed_orig:
+            assert line in graph_str
+
+
+# examples of dot files used in the following test
+dotfile_detailed_iter_exec = [
+    'digraph structs {\n',
+    'node [shape=record];\n',
+    'pipemod1aIa1 [label="{IN}|{ a1 | engine | mod1.aI }|{OUT|<outoutput1> output1}"];\n',
+    'pipemod2a1 [label="{IN|<ininput1> input1}|{ a1 | engine | mod2 }|{OUT}"];\n',
+    'pipemod1aIa0 [label="{IN}|{ a0 | engine | mod1.aI }|{OUT|<outoutput1> output1}"];\n',
+    'pipemod2a0 [label="{IN|<ininput1> input1}|{ a0 | engine | mod2 }|{OUT}"];\n',
+    'pipemod1aIa0:outoutput1:e -> pipemod2a0:ininput1:w;\n',
+    'pipemod1aIa1:outoutput1:e -> pipemod2a1:ininput1:w;\n',
+    '}']
+
+dotfile_iter_hierarchical = [
+    'digraph pipe{\n',
+    '  label="pipe";\n',
+    '  pipe_mod1[label="mod1 (engine)", shape=box3d,style=filled, color=black, colorscheme=greys7 fillcolor=2];\n',
+    '  pipe_mod2[label="mod2 (engine)"];\n',
+    '  pipe_mod1 -> pipe_mod2;\n',
+    '}']
+
+dotfile_iter_colored = [
+    'digraph pipe{\n',
+    '  label="pipe";\n',
+    '  pipe_mod1[label="mod1 (engine)", shape=box3d,style=filled, color=black, colorscheme=greys7 fillcolor=2];\n',
+    '  pipe_mod2[label="mod2 (engine)", style=filled, fillcolor="#FFFFC8"];\n',
+    '  pipe_mod1 -> pipe_mod2;\n',
+    '}']
+
+dotfiles_iter = {
+    "orig": dotfile_orig,
+    "flat": dotfile_orig,
+    "exec": dotfile_orig,
+    "hierarchical": dotfile_iter_hierarchical,
+    "colored": dotfile_iter_colored
+    }
+
+dotfiles_detailed_iter = {
+    "orig": dotfile_detailed_orig,
+    "flat": dotfile_detailed_orig,
+    "exec": dotfile_detailed_iter_exec
+    }
+
+@pytest.mark.parametrize("simple", [True, False])
+@pytest.mark.parametrize("graph_type", ['orig', 'flat', 'exec', 'hierarchical', 'colored'])
+def test_write_graph_dotfile_iterables(tmpdir, graph_type, simple):
+    """ checking dot files for a workflow with iterables"""
+    tmpdir.chdir()
+
+    pipe = pe.Workflow(name='pipe')
+    mod1 = pe.Node(interface=EngineTestInterface(), name='mod1')
+    mod1.iterables = ('input1', [1, 2])
+    mod2 = pe.Node(interface=EngineTestInterface(), name='mod2')
+    pipe.connect([(mod1, mod2, [('output1', 'input1')])])
+    pipe.write_graph(
+        graph2use=graph_type, simple_form=simple, format='dot')
+
+    with open("graph.dot") as f:
+        graph_str = f.read()
+
+    if simple:
+        for line in dotfiles_iter[graph_type]:
+            assert line in graph_str
+    else:
+        # if simple=False graph.dot uses longer names
+        for line in dotfiles_iter[graph_type]:
+            if graph_type in ["hierarchical", "colored"]:
+                assert line.replace("mod1 (engine)", "mod1.EngineTestInterface.engine").replace(
+                    "mod2 (engine)", "mod2.EngineTestInterface.engine") in graph_str
+            else:
+                assert line.replace(
+                    "mod1 (engine)", "pipe.mod1.EngineTestInterface.engine").replace(
+                    "mod2 (engine)", "pipe.mod2.EngineTestInterface.engine") in graph_str
+
+    # graph_detailed is not created for hierachical or colored
+    if graph_type not in ["hierarchical", "colored"]:
+        with open("graph_detailed.dot") as f:
+            graph_str = f.read()
+        for line in dotfiles_detailed_iter[graph_type]:
+            assert line in graph_str
+
+
+
 def test_io_subclass():
     """Ensure any io subclass allows dynamic traits"""
     from nipype.interfaces.io import IOBase

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
click==8.0.4
codecov==2.1.13
configparser==5.2.0
coverage==6.2
cycler==0.11.0
decorator==4.4.2
docutils==0.18.1
execnet==1.9.0
funcsigs==1.0.2
future==1.0.0
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
isodate==0.6.1
Jinja2==3.0.3
kiwisolver==1.3.1
lxml==5.3.1
MarkupSafe==2.0.1
matplotlib==3.3.4
mock==5.2.0
networkx==2.5.1
nibabel==3.2.2
-e git+https://github.com/nipy/nipype.git@69dce12bdf256c3bb0a8b6da9a1d1cdce48b66ec#egg=nipype
numpy==1.19.5
numpydoc==1.1.0
packaging==21.3
Pillow==8.4.0
pluggy==1.0.0
prov==1.5.0
py==1.11.0
pydot==1.4.2
pydotplus==2.0.2
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
pytest-env==0.6.2
pytest-xdist==3.0.2
python-dateutil==2.9.0.post0
pytz==2025.2
rdflib==5.0.0
requests==2.27.1
scipy==1.5.4
simplejson==3.20.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli==1.2.3
traits==6.4.1
typing_extensions==4.1.1
urllib3==1.26.20
yapf==0.32.0
zipp==3.6.0

name: nipype
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - click==8.0.4
      - codecov==2.1.13
      - configparser==5.2.0
      - coverage==6.2
      - cycler==0.11.0
      - decorator==4.4.2
      - docutils==0.18.1
      - execnet==1.9.0
      - funcsigs==1.0.2
      - future==1.0.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - isodate==0.6.1
      - jinja2==3.0.3
      - kiwisolver==1.3.1
      - lxml==5.3.1
      - markupsafe==2.0.1
      - matplotlib==3.3.4
      - mock==5.2.0
      - networkx==2.5.1
      - nibabel==3.2.2
      - numpy==1.19.5
      - numpydoc==1.1.0
      - packaging==21.3
      - pillow==8.4.0
      - pluggy==1.0.0
      - prov==1.5.0
      - py==1.11.0
      - pydot==1.4.2
      - pydotplus==2.0.2
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-env==0.6.2
      - pytest-xdist==3.0.2
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - rdflib==5.0.0
      - requests==2.27.1
      - scipy==1.5.4
      - simplejson==3.20.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tomli==1.2.3
      - traits==6.4.1
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - yapf==0.32.0
      - zipp==3.6.0
prefix: /opt/conda/envs/nipype

nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[exec-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[exec-False]
nipype/pipeline/engine/tests/test_engine.py::test_parameterize_dirs_false
nipype/pipeline/engine/tests/test_engine.py::test_2mods[iterables0-expected0] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[hierarchical-True] nipype/pipeline/engine/tests/test_engine.py::test_1mod[iterables0-expected0] nipype/pipeline/engine/tests/test_engine.py::test_io_subclass nipype/pipeline/engine/tests/test_engine.py::test_iterable_expansion nipype/pipeline/engine/tests/test_engine.py::test_synchronize_expansion nipype/pipeline/engine/tests/test_engine.py::test_3mods[iterables1-expected1-connect1] nipype/pipeline/engine/tests/test_engine.py::test_3mods[iterables0-expected0-connect0] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[colored-False] nipype/pipeline/engine/tests/test_engine.py::test_itersource_synchronize1_expansion nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[hierarchical-False] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[hierarchical-False] nipype/pipeline/engine/tests/test_engine.py::test_expansion nipype/pipeline/engine/tests/test_engine.py::test_itersource_expansion nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[colored-True] nipype/pipeline/engine/tests/test_engine.py::test_3mods[iterables2-expected2-connect2] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[colored-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[exec-False] nipype/pipeline/engine/tests/test_engine.py::test_old_config nipype/pipeline/engine/tests/test_engine.py::test_2mods[iterables1-expected1] nipype/pipeline/engine/tests/test_engine.py::test_itersource_synchronize2_expansion nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[flat-False] nipype/pipeline/engine/tests/test_engine.py::test_1mod[iterables1-expected1] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[colored-False] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[hierarchical-True] nipype/pipeline/engine/tests/test_engine.py::test_2mods[iterables2-expected2] nipype/pipeline/engine/tests/test_engine.py::test_synchronize_tuples_expansion nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[orig-False] nipype/pipeline/engine/tests/test_engine.py::test_mapnode_json nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[exec-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[orig-False] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[orig-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[orig-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[flat-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile_iterables[flat-False] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_dotfile[flat-True] nipype/pipeline/engine/tests/test_engine.py::test_write_graph_runs nipype/pipeline/engine/tests/test_engine.py::test_deep_nested_write_graph_runs nipype/pipeline/engine/tests/test_engine.py::test_serial_input
nipype/pipeline/engine/utils.py nipype/pipeline/engine/base.py nipype/pipeline/engine/nodes.py
nipype/pipeline/engine/utils.py nipype/pipeline/engine/base.py nipype/pipeline/engine/nodes.py