AhmedSiddiquewrote:
Cost means value of a path
The correct term for it is "weight". Please see:
http://en.wikipedia.org/wiki/Graph_%28mathematics%29#Weighted_graph[
^].
This feature my or may no be implemented. Is it not? Not to worry. Remember that you don't require a graphs of general structure, you merely need trees, which makes most problems extremely simplified:
http://en.wikipedia.org/wiki/Tree_%28graph_theory%29[
^].
In particular, take that weight. If you think just a bit, you can see that the workaround is very simple: you can conveniently store the weight in each node. Why? Because, in a tree, every node has 0 or 1 parents, 0 only for a root node. So, you will store weight of all edges, as each node (except the root, which you can simply ignore, no matter what it stores) has only one edge connecting it to its parent. When you store some weight value in each node except the root, you have all you edges weighted. Problem solved.
Again, why won't you use one of the
TreeView
classes available in .NET FCL? This is another solution, and the problem of weights is solved in exact same way as I explained above.
—SA