Highlighting specific nodes and the link between them programaticaly

I have an array of keys, and I want to highlight the nodes corresponding to these keys, with the links between them.
Is there a way to do this programmatically?

First, highlighting the nodes, including unhighlighting nodes whose keys are not in your array:

  var keys = new go.Set().addAll(myArrayOfKeys);
  myDiagram.nodes.each(function(n) {
      n.isHighlighted = keys.contains(node.data.key);

Second, highlighting any directly connected links:

  myDiagram.links.each(function(l) {
      l.isHighlighted = keys.contains(l.fromNode.data.key) &&

Third, you need to change your node and link templates so that they appear the way that you want them to based on Bindings depending on Part.isHighlighted. Read GoJS Highlighting -- Northwoods Software.

Works perfectly
Thank you so much

what was missing from my knowledge was go.Set().addAll(myArrayOfKeys)

Using a Set is not necessary, but it’s more efficient if there might be a lot of keys.

Hi, we are playing with this. And we just want to highlight in a certain order with an array of provided keys. i.e. 1,3,9,10

Connections go both ways on all of them, but we just want to highlight in the direction they are listed. 1 to 3, 3 to 9, 9 to 10.

Have you seen the Distances sample? In particular, you’ll notice the highlightPath function uses Node.findLinksTo.