MCPcopy
hub / github.com/tensorflow/playground / drawLink

Function drawLink

src/playground.ts:752–788  ·  view source on GitHub ↗
(
    input: nn.Link, node2coord: {[id: string]: {cx: number, cy: number}},
    network: nn.Node[][], container,
    isFirst: boolean, index: number, length: number)

Source from the content-addressed store, hash-verified

750}
751
752function drawLink(
753 input: nn.Link, node2coord: {[id: string]: {cx: number, cy: number}},
754 network: nn.Node[][], container,
755 isFirst: boolean, index: number, length: number) {
756 let line = container.insert("path", ":first-child");
757 let source = node2coord[input.source.id];
758 let dest = node2coord[input.dest.id];
759 let datum = {
760 source: {
761 y: source.cx + RECT_SIZE / 2 + 2,
762 x: source.cy
763 },
764 target: {
765 y: dest.cx - RECT_SIZE / 2,
766 x: dest.cy + ((index - (length - 1) / 2) / length) * 12
767 }
768 };
769 let diagonal = d3.svg.diagonal().projection(d => [d.y, d.x]);
770 line.attr({
771 "marker-start": "url(#markerArrow)",
772 class: "link",
773 id: "link" + input.source.id + "-" + input.dest.id,
774 d: diagonal(datum, 0)
775 });
776
777 // Add an invisible thick link that will be used for
778 // showing the weight value on hover.
779 container.append("path")
780 .attr("d", diagonal(datum, 0))
781 .attr("class", "link-hover")
782 .on("mouseenter", function() {
783 updateHoverCard(HoverType.WEIGHT, input, d3.mouse(this));
784 }).on("mouseleave", function() {
785 updateHoverCard(null);
786 });
787 return line;
788}
789
790/**
791 * Given a neural network, it asks the network for the output (prediction)

Callers 1

drawNetworkFunction · 0.85

Calls 1

updateHoverCardFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…