diff --git a/tensorflow/tensorboard/components/tf_graph_common_d3v4/edge.ts b/tensorflow/tensorboard/components/tf_graph_common_d3v4/edge.ts
index f3768e169b7..45755ee8f56 100644
--- a/tensorflow/tensorboard/components/tf_graph_common_d3v4/edge.ts
+++ b/tensorflow/tensorboard/components/tf_graph_common_d3v4/edge.ts
@@ -87,7 +87,7 @@ export function buildGroup(sceneGroup,
 
   // Select all children and join with data.
   // (Note that all children of g.edges are g.edge)
-  let edgeGroups = (container as any).selectAll('g.edge').data(edges, getEdgeKey);
+  let edgeGroups = (container as any).selectAll(function() {return this.childNodes;}).data(edges, getEdgeKey);
 
   // Make edges a group to support rendering multiple lines for metaedge
   edgeGroups.enter()
diff --git a/tensorflow/tensorboard/components/tf_graph_common_d3v4/node.ts b/tensorflow/tensorboard/components/tf_graph_common_d3v4/node.ts
index 6d66bb69d9c..0e0ceca1d19 100644
--- a/tensorflow/tensorboard/components/tf_graph_common_d3v4/node.ts
+++ b/tensorflow/tensorboard/components/tf_graph_common_d3v4/node.ts
@@ -66,8 +66,7 @@ module tf.graph.scene.node {
     // Select all children and join with data.
     // (Note that all children of g.nodes are g.node)
     let nodeGroups =
-        (container as any)
-            .selectAll('g.node')
+        (container as any).selectAll(function() {return this.childNodes;})
             .data(nodeData, (d) => {
               // make sure that we don't have to swap shape type
               return d.node.name + ':' + d.node.type;