Let g
be a directed weighted graph (in particular is tree). Given a set of vertices A
, how can I extract the weights in a set B
having the following feature
Each weight in B labels an edge which starts from a vertex in A.
Being the graph a tree, then a unique edge starts from a vertex. Clearly for a tree, the extraction is conceptually easier. However the extraction procedure seems to be a standard procedure.
For example the graph is
g = Graph[{1 -> 2, 3 -> 2, 2 -> 4, 4 -> 5}, EdgeWeight -> {0.3, 0.4, 0.5, 0.7}]
The subset of vertices is A={1,3}
. The weight 0.3
is associated with node 1.
The weight 0.4
is associated with node 3.
Thanks very much.