Searches the graph for all nodes reachable from ANode. The method marks every node reachable with Visited = True. The method uses the
InitializeNodes and
DepthFirstSearch methods to do its work.
Namespace: GGraph
Delphi
|
public
procedure TraverseFrom( StartNode: TGGraphNode );
|
Parameters
StartNode
Type: TGGraphNode
The following code prints out all the nodes reachable from node 1:
Delphi
|
begin
// call InitializeNodes and DepthFirstSearch. Alternatively, just call TraverseFrom
Graph.InitializeNodes;
Graph.DepthFirstSearch( Node1 );
// Graph.TraverseFrom( Node1 );
with Graph.GetNodes do
while HasMoreElements do
with TGGraphNode(NextElement) do
if Visited then
ListBox1.Items.Add( 'node ' + Caption + ' is reachable' )
else
ListBox1.Items.Add( 'node ' + Caption + ' is not reachable' );
end;
|