Repository: iterative/dvc

Issue:
dvc pipeline show --ascii - visual bug since version 0.82.9
DVC version: 0.82.9 and following
reproduced on several platforms, like:
4.15.0-55-generic #60-Ubuntu
macOS High Sierra 10.13.6
macOS Catalina 10.15.2

Hi,

the command "dvc pipeline show --ascii" seems to have a bug since version 0.89.9, which does not display the dependencies properly, when there is a branch in a Pipeline. 

I created a simple pipeline, which looks like this:

**Pipeline with Version 0.82.8**
<img width="440" alt="Pipeline with Version 0.82.8" src="https://user-images.githubusercontent.com/58767298/75341258-5e606080-5894-11ea-8317-5ddeaf79f5c2.png">


If i use the command "dvc pipeline show --ascii validation.dvc" with version 0.82.8, the whole pipeline gets displayed properly.
If i upgrade my Version to e.g. 0.83.0, the connection between "val.dvc" and the previous Stage is missing. If i use the command on val.dvc itself, the stages "train.dvc" and "validation.dvc" are missing (see screenshots).


**Pipeline with Version 0.83.0**
<img width="453" alt="Pipeline with Version 0.83.0" src="https://user-images.githubusercontent.com/58767298/75341262-5f918d80-5894-11ea-841c-e59b56dfed33.png">

**Pipeline with Version 0.83.0, when using val.dvc in the command**
<img width="227" alt="Pipeline with Version 0.83.0, when using val.dvc in the command" src="https://user-images.githubusercontent.com/58767298/75341265-5f918d80-5894-11ea-9a35-0e53619e5c55.png">





Discussion:
Can confirm that issue still exists.
Reproduction script:

```
#!/bin/bash

rm -rf repo
mkdir repo

pushd repo
git init --quiet
dvc init -q

echo data>>data
dvc add data

dvc run -d data -f dvc_run.dvc -o processed_data "cat data>>processed_data"
dvc run -d processed_data -o val "cat processed_data>>val"
dvc run -d processed_data -o train "cat processed_data>>train"
dvc run -d val -d train -o validation "echo validated >> validation"
dvc pipeline show --ascii validation.dvc
```
Might be caused by https://github.com/iterative/dvc/pull/3217

Resolving patch:
diff --git a/dvc/command/pipeline.py b/dvc/command/pipeline.py
--- a/dvc/command/pipeline.py
+++ b/dvc/command/pipeline.py
@@ -61,7 +61,7 @@ def _build_graph(self, target, commands, outs):
                     for out in stage.outs:
                         edges.append((str(out), str(dep)))
         else:
-            for from_stage, to_stage in networkx.dfs_edges(G, target_stage):
+            for from_stage, to_stage in networkx.edge_dfs(G, target_stage):
                 if commands:
                     if to_stage.cmd is None:
                         continue


Test patch:
diff --git a/tests/func/test_pipeline.py b/tests/func/test_pipeline.py
--- a/tests/func/test_pipeline.py
+++ b/tests/func/test_pipeline.py
@@ -237,3 +237,29 @@ def locked_stage(self):
 
         pipelines = self.dvc.pipelines
         self.assertEqual(len(pipelines), 0)
+
+
+def test_split_pipeline(tmp_dir, dvc):
+    tmp_dir.dvc_gen("data", "source file content")
+    dvc.run(
+        deps=["data"],
+        outs=["data_train", "data_valid"],
+        cmd="echo train >> data_train && echo valid >> data_valid",
+    )
+    stage = dvc.run(
+        deps=["data_train", "data_valid"],
+        outs=["result"],
+        cmd="echo result >> result",
+    )
+
+    command = CmdPipelineShow([])
+    nodes, edges, is_tree = command._build_graph(
+        stage.path, commands=False, outs=True
+    )
+    assert set(nodes) == {"data", "data_train", "data_valid", "result"}
+    assert set(edges) == {
+        ("result", "data_train"),
+        ("result", "data_valid"),
+        ("data_train", "data"),
+        ("data_valid", "data"),
+    }