public void HighlightingLink(SankeyLinkFinder linkFinder, IReadOnlyDictionary <int, IReadOnlyList <SankeyNode> > nodes, IReadOnlyList <SankeyLink> links)
        {
            if (linkFinder == null && diagram.HighlightLink == null || nodes == null || nodes.Count < 2 || links == null || links.Count == 0)
            {
                return;
            }

            // reset each element's brush first
            RecoverHighlights(links, false);

            var resetBrushes   = true;
            var highlightNodes = new List <string>();
            var minimizeNodes  = new List <string>();

            // check whether highlight node exist
            if (linkFinder != null)
            {
                var fromNode = (from node in nodes.Values.SelectMany(n => n) where node.Name == linkFinder.From select node).FirstOrDefault();
                var toNode   = (from node in nodes.Values.SelectMany(n => n) where node.Name == linkFinder.To select node).FirstOrDefault();

                if (fromNode != null && toNode != null)
                {
                    if ((from link in links where link.FromNode.Name == linkFinder.From & link.ToNode.Name == linkFinder.To select link).Count() > 0)
                    {
                        resetBrushes = false;
                    }
                }
                ;
            }

            // reset highlight if highlighting the same link twice
            if (diagram.HighlightLink != null && linkFinder != null)
            {
                if ((diagram.HighlightLink.From == linkFinder.From && diagram.HighlightLink.To == linkFinder.To) && (from link in links where (link.FromNode.Name == diagram.HighlightLink.From && link.ToNode.Name == diagram.HighlightLink.To) & link.IsHighlight select link).Count() == 1)
                {
                    RecoverHighlights(links);
                    ClearHighlight();

                    return;
                }
            }

            if (linkFinder == null)
            {
                return;
            }

            // for node, link highlighting switching
            diagram.SetCurrentValue(SankeyDiagram.HighlightNodeProperty, null);

            // increasing opacity of the correlated element while lower the others
            Highlighting(links, resetBrushes, diagram.HighlightOpacity, diagram.LoweredOpacity, highlightNodes, minimizeNodes, new Func <SankeyLink, bool>(link => { return(link.FromNode.Name == linkFinder.From && link.ToNode.Name == linkFinder.To); }));
        }
        public void HighlightingLink(SankeyLinkFinder linkStyleFinder, Dictionary<int, List<SankeyNode>> nodes, List<SankeyLink> links)
        {
            if ((linkStyleFinder == null && diagram.HighlightLink == null || nodes == null || nodes.Count < 2 || links == null || links.Count == 0))
            {
                return;
            }

            // reset each element's style first
            RecoverFromHighlights(links, false);

            var resetBrushes = true;
            var highlightNodes = new List<string>();
            var minimizeNodes = new List<string>();

            // check whether highlight node exist
            if (linkStyleFinder != null)
            {
                var fromNode = (from node in nodes.Values.SelectMany(n => n) where node.Label.Text == linkStyleFinder.From select node).FirstOrDefault();
                var toNode = (from node in nodes.Values.SelectMany(n => n) where node.Label.Text == linkStyleFinder.To select node).FirstOrDefault();

                if (fromNode != null && toNode != null)
                {
                    if ((from link in links where link.FromNode.Label.Text == linkStyleFinder.From & link.ToNode.Label.Text == linkStyleFinder.To select link).Count() > 0)
                    {
                        resetBrushes = false;
                    }
                };
            }

            // reset highlight if highlighting the same link twice
            if (diagram.HighlightLink != null && linkStyleFinder != null)
            {
                if ((diagram.HighlightLink.From == linkStyleFinder.From && diagram.HighlightLink.To == linkStyleFinder.To) && (from link in links where (link.FromNode.Label.Text == diagram.HighlightLink.From && link.ToNode.Label.Text == diagram.HighlightLink.To) & link.IsHighlight select link).Count() == 1)
                {
                    RecoverFromHighlights(links);

                    return;
                }
            }

            // for node, link highlighting switching
            diagram.HighlightNode = null;

            // increasing opacity of the correlated element while lower the others
            Highlighting(links, resetBrushes, diagram.HighlightOpacity, diagram.LoweredOpacity, highlightNodes, minimizeNodes, new Func<SankeyLink, bool>(link => { return link.FromNode.Label.Text == linkStyleFinder.From && link.ToNode.Label.Text == linkStyleFinder.To; }));
        }