(
input: nn.Link, node2coord: {[id: string]: {cx: number, cy: number}},
network: nn.Node[][], container,
isFirst: boolean, index: number, length: number)
| 750 | } |
| 751 | |
| 752 | function 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) |
no test coverage detected
searching dependent graphs…