The following example finds all the nodes that are linked to ContextNode node, selectedNode. If selectedNode is not a destination node, the destination node is added to an ArrayList, destinationNodes. If selectedNode is not the source node, it is added to an ArrayList, sourceNodes.
ArrayList destinationNodes = new ArrayList();
ArrayList sourceNodes = new ArrayList();
// Find all the nodes that link to the currently selected node.foreach (Microsoft.Ink.ContextLink link in selectedNode.Links)
if (link.DestinationNode != selectedNode)
if (link.SourceNode != selectedNode)