Change go.Shape color when connected with link

I want to change the color of shape present in the node when two nodes are connected, i have the following properties for diagram.
linkToPortIdProperty: “toPort”,
linkFromPortIdProperty: “fromPort”,
and on the node properties are,
fromLinkable: true,
toLinkable: true,

example:
Frame 145

You can use Node.linkConnected and Node.linkDisconnected.

May i get to see any example where this is used?

Thanks a lot jhardy!