Graphviz lines do not touch custom made svg images as nodes

I am trying to produce this graph
digraph {
A [label="" image=“router.svg” shape=none]
B [label="" image=“switch.svg” shape=none]
C [label="" image=“router.svg” shape=none]
D [label="" image=“router.svg” shape=none]
E [label="" image=“switch.svg” shape=none]
F [label="" image=“router.svg” shape=none]
A -> B [arrowhead=none constraint=false]
B -> C [arrowhead=none constraint=false]
C -> D [arrowhead=none constraint=false]
D -> E [arrowhead=none constraint=false]
E -> F [arrowhead=none constraint=false]

This renders the svg images of a router and a switch, but the lines to link them do not touch any of them, they come short. I wonder if this might be a setting in Graphviz or related to the svg as such. Would you please help me to shed a light.
Here are the svgs.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>


<?xml version="1.0" encoding="UTF-8" standalone="no"?>

I don’t have your router image. Could you please show how the dot output looks?
Did you play already with “head” related attributes?
Maybe the router image has a background?

Hi. Sorry I didn’t include the image, I have attached the rendered image.

I have not played with the head attributes, I will look into that. I did play though with imagescale and the lines got a bit closer, but not enough as to touch the real edges of the image. If you have any advice please let me know.
I am trying to upload/attach the router and the switch svg files, but don’t know What I am doing wrong this application doesn’t let me do so.

you don’t see the head of the line at all. I assume size of images isn’t known to Graphviz and hence assumed smaller than in reality. In addition, you have a background on the images.

If someone wants to work on improved shape clipping of custom shapes, clip_and_install and poly_inside are good places to start reading.

It will take some exploration to learn how shapes are represented internally after being loaded (and rendered into pixels?). I’m inferring your proposal may be to define that a point is outside the boundary of a custom shape, if that point lands on a transparent pixel (assuming your shapes are transparent outside the boundary of the symbol as well). What if the shape contains transparent pixels inside the symbol? (It may not matter much.)

This feature will depend on the availability of libraries (at compile time) to render external SVG (or other formats) into pixels and all the associated machinery, but we’ve already bought into that, at least as a build-time option. The proposed feature would not be available if someone builds a minimal graphviz with just libgd and no shape loader/renderer. Almost every day I see complaints on Twitter or elsewhere about all the dependencies graphviz needs, but there’s no way around it for features like this.

As Vithanco suggested, the background of the svg images is causing the problem (i.e. there is a white boundary around the router & switch images). If your images were bitmap images (png, jpeg, …) they would be easier to trim - but you can trim svg images without too much work.

  1. Download Inkscape ( to your computer (Windows, Linus, MacOS). You can use it to edit the svg icons.
  2. Open the router.svg file. Note the border around the image. That is causing your problem.
  3. Click in the middle of the image. Note the dashed lines that seem to trim the image.
  4. Click on Edit, and Resize page to Selection
  5. Finally Save As

Yes. The problem was the image. I tried the steps above for inkscape, but no luck the background is not removed, so I tried changing values inside the svg but no luck there either, so I decided to redraw the svg images on inkscape, that fixed my problem.
If it is not much to ask, do you know how to remove the background on jpeg images, which tool?
Thanks so much for your help.

If you are only going to crop (fix) a few images:

  • On Windows: Try Microsoft Photos, Microsoft Paint, or Gimp
  • On Linux: Try Gimp or ImageMagick
  • On Apple: Sorry, not sure

If you have many (dozens or more) images to crop, look into the pnmcrop program that is part of netpbm package.

I would most likely use Pixelmator Pro on the Mac.

Thanks so much.