Share via


GraphNode.FindRelatedNodes Method

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.

Namespace:  Microsoft.VisualStudio.GraphModel
Assembly:  Microsoft.VisualStudio.GraphModel (in Microsoft.VisualStudio.GraphModel.dll)

Syntax

'Declaration
Public Function FindRelatedNodes ( _
    searchDirection As GraphSearchDirection, _
    traverseLink As Predicate(Of GraphLink), _
    traverseNode As Predicate(Of GraphNode), _
    acceptNode As Predicate(Of GraphNode) _
) As IEnumerable(Of GraphNode)
public IEnumerable<GraphNode> FindRelatedNodes(
    GraphSearchDirection searchDirection,
    Predicate<GraphLink> traverseLink,
    Predicate<GraphNode> traverseNode,
    Predicate<GraphNode> acceptNode
)
public:
IEnumerable<GraphNode^>^ FindRelatedNodes(
    GraphSearchDirection searchDirection, 
    Predicate<GraphLink^>^ traverseLink, 
    Predicate<GraphNode^>^ traverseNode, 
    Predicate<GraphNode^>^ acceptNode
)
member FindRelatedNodes : 
        searchDirection:GraphSearchDirection * 
        traverseLink:Predicate<GraphLink> * 
        traverseNode:Predicate<GraphNode> * 
        acceptNode:Predicate<GraphNode> -> IEnumerable<GraphNode> 
public function FindRelatedNodes(
    searchDirection : GraphSearchDirection, 
    traverseLink : Predicate<GraphLink>, 
    traverseNode : Predicate<GraphNode>, 
    acceptNode : Predicate<GraphNode>
) : IEnumerable<GraphNode>

Parameters

  • traverseLink
    Type: Predicate<GraphLink>

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

  • traverseNode
    Type: Predicate<GraphNode>

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

  • acceptNode
    Type: 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: IEnumerable<GraphNode>
An iterator over the related nodes that were found returned in depth first order, an empty iterator otherwise

Remarks

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);

.NET Framework Security

See Also

Reference

GraphNode Class

Microsoft.VisualStudio.GraphModel Namespace