GraphNode::FindRelatedNodes Method (GraphSearchDirection, Predicate<GraphLink^>^, Predicate<GraphNode^>^, Predicate<GraphNode^>^)
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.
Assembly: Microsoft.VisualStudio.GraphModel (in Microsoft.VisualStudio.GraphModel.dll)
public:
IEnumerable<GraphNode^>^ FindRelatedNodes(
GraphSearchDirection searchDirection,
Predicate<GraphLink^>^ traverseLink,
Predicate<GraphNode^>^ traverseNode,
Predicate<GraphNode^>^ acceptNode
)
Parameters
- searchDirection
-
Type:
Microsoft.VisualStudio.GraphModel::GraphSearchDirection
Pass Source to search nodes that link to this node.
- traverseLink
-
Type:
System::Predicate<GraphLink^>^
A predicate function to control link traversal behavior, pass null if you want to traverse all links
- traverseNode
-
Type:
System::Predicate<GraphNode^>^
A predicate to control node traversal behavior, pass null if you want to traverse all reachable nodes
- acceptNode
-
Type:
System::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
Return Value
Type: System.Collections.Generic::IEnumerable<GraphNode^>^An iterator over the related nodes that were found returned in depth first order, an empty iterator otherwise
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 => true, n => true, n => HasCategory(MethodCategory);