Share via


GraphNode.FindRelatedNodes Method

Definition

Finds the dgml nodes that matches the acceptNode predicate and are related in a way that matches the traverseLink and traverseNode predicates.
They are found by doing a breadth first search along links matching the traverseLink predicate, in the Source or Target direction designated by the searchDirection parameter. Then if the node matches the traverseNode predicate it keeps searching recurrsively through that node in the same direction and returns all nodes that match the acceptNode predicate. The search can handle circularity in the graph.

public:
 System::Collections::Generic::IEnumerable<Microsoft::VisualStudio::GraphModel::GraphNode ^> ^ FindRelatedNodes(Microsoft::VisualStudio::GraphModel::GraphSearchDirection searchDirection, Predicate<Microsoft::VisualStudio::GraphModel::GraphLink ^> ^ traverseLink, Predicate<Microsoft::VisualStudio::GraphModel::GraphNode ^> ^ traverseNode, Predicate<Microsoft::VisualStudio::GraphModel::GraphNode ^> ^ acceptNode);
[System.Runtime.CompilerServices.IteratorStateMachine(typeof(Microsoft.VisualStudio.GraphModel.GraphNode+<FindRelatedNodes>d__45))]
public System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.GraphModel.GraphNode> FindRelatedNodes (Microsoft.VisualStudio.GraphModel.GraphSearchDirection searchDirection, Predicate<Microsoft.VisualStudio.GraphModel.GraphLink> traverseLink, Predicate<Microsoft.VisualStudio.GraphModel.GraphNode> traverseNode, Predicate<Microsoft.VisualStudio.GraphModel.GraphNode> acceptNode);
[<System.Runtime.CompilerServices.IteratorStateMachine(typeof(Microsoft.VisualStudio.GraphModel.GraphNode+<FindRelatedNodes>d__45))>]
member this.FindRelatedNodes : Microsoft.VisualStudio.GraphModel.GraphSearchDirection * Predicate<Microsoft.VisualStudio.GraphModel.GraphLink> * Predicate<Microsoft.VisualStudio.GraphModel.GraphNode> * Predicate<Microsoft.VisualStudio.GraphModel.GraphNode> -> seq<Microsoft.VisualStudio.GraphModel.GraphNode>
Public Iterator Function FindRelatedNodes (searchDirection As GraphSearchDirection, traverseLink As Predicate(Of GraphLink), traverseNode As Predicate(Of GraphNode), acceptNode As Predicate(Of GraphNode)) As IEnumerable(Of GraphNode)

Parameters

searchDirection
GraphSearchDirection

Pass Source to search nodes that link to this node. Pass Target to search nodes that are linked from this node

traverseLink
Predicate<GraphLink>

A predicate function to control link traversal behavior, pass null if you want to traverse all links

traverseNode
Predicate<GraphNode>

A predicate to control node traversal behavior, pass null if you want to traverse all reachable nodes

acceptNode
Predicate<GraphNode>

A predicate to control if a node is to be included in the search or not, pass null if you want to accept all nodes

Returns

An iterator over the related nodes that were found returned in depth first order, an empty iterator otherwise

Attributes

Examples

The following example searches through all nodes reachable via all links from the start node and returns all nodes that have the Method category:

start.FindRelatedNodes(GraphSearchDirection.Target, l =&gt; true, n =&gt; true, n =&gt; HasCategory(MethodCategory);

Applies to