Hi,
I have created a graph using the tcllib package, struct::graph. Now i want to perform a bfs traversal on the geraph, In the package it has been specified that we have to use the function "walk" for performing traversal on the graph. In that function there is a field called "-command cmd" , can somebody help me as what value i have to specify in that field.
Thanks
Deepak
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As the walk progresses, the command cmd will be evaluated at each node,
with the mode of the call (enter or leave) and values graphName and the name of the current node appended.
I.e. the command is called for each node visited by the walk.
It is called like
uplevel #0 $cmd [list $mode $graph $node]
So, the command can be a procedure X, defined as
proc X {mode graph node} {
...
}
Does this help ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have created a graph using the tcllib package, struct::graph. Now i want to perform a bfs traversal on the geraph, In the package it has been specified that we have to use the function "walk" for performing traversal on the graph. In that function there is a field called "-command cmd" , can somebody help me as what value i have to specify in that field.
Thanks
Deepak
The documentation at http://docs.activestate.com/activetcl/8.5/tcllib/struct/graph.html#67
says:
I.e. the command is called for each node visited by the walk.
It is called like
So, the command can be a procedure X, defined as
Does this help ?
Hi,
Can you please specify what should i write inside the procedure X. I need to display the node names.
Thanks
Deepak
Hi,
If my start node is "node1", order is "pre" , type is "bfs" , object name is "my" and dir is "forward" ,the command will look like the following
my walk node1 -order pre -type bfs -dir forward -command cmd
I have the doubt , what value should i specify for cmd?
Thanks
Deepak
Re:
The node name is the 'node' argument of X.
Therefore
is what you want.
If the node name you speak of is an attribute of the node itself, then it would be more like
where '<attribute>' is my placeholder for the name of the attribute holding the node name.
Re:
The cmd is independent of the other options. You choose the name of the procedure to use, and then use that name as the cmd.
In the example shown in my first reply I choose to name the procedure "X". You are free to use whatever name you want.
Hi
Thank You.
Regards
Deepak