# 5.19 Weighted Multiway Graphs

In a multiway system, there are in general multiple paths that can produce the same state. But in our usual construction of the multiway graph, we record only what states are produced, not how many paths can do it.

Consider the rule:

{"A" -> "AA", "A" -> "A"}

The full form of its multiway graphincluding an edge for every possible eventis:

ResourceFunction["MultiwaySystem"][{"A" -> "AA", "A" -> "A"}, "A", 4, "EvolutionGraphFull"]

Here is the same graph, with a count included at each node for the number of distinct paths from the root that reach it:

Graph[ResourceFunction["MultiwaySystem"][{"A" -> "AA", "A" -> "A"}, "A", 4, "EvolutionGraphFull", "IncludeStatePathWeights" -> True], VertexLabels -> "VertexWeight"]

An alternative weighting scheme might be to start with weight 1 for the initial state, then at each state we reach, to distribute the weight to its successors, dividing it equally among possible events:

Graph[ResourceFunction["MultiwaySystem"][{"A" -> "AA", "A" -> "A"}, "A", 4, "EvolutionGraphFull", "IncludeStateWeights" -> True], VertexLabels -> "VertexWeight"]

This approach has the feature that it gives normalized weights (summing to 1) at each successive layer in a graph like this. But in general the approach is not robust, and if we even took a different foliation through the graph above, the weights on each slice would no longer be normalized. In addition, if we were to combine identical states from different steps, we would not know what weights to assign. Pure counting of paths, however, still works even in this case, although any normalization has to be done only after all the counts are known:

Graph[ResourceFunction["MultiwaySystem"][{"A" -> "AA", "A" -> "A"}, "A", 4, "StatesGraph", "IncludeStatePathWeights" -> True], VertexLabels -> "VertexWeight"]

Note that even the counting of paths becomes difficult to define if there is a loop in the multiway graphthough one can adopt the convention that one counts paths only to the first encounter with any given state:

Graph[ResourceFunction["MultiwaySystem"][{"AB" -> "BAB", "BA" -> "A"}, "ABA", 4, "StatesGraph", "IncludeStatePathWeights" -> True], VertexLabels -> "VertexWeight"] // LayeredGraphPlot

Weights on the multiway graph can also be inherited by branchial graphs. Consider for example the rule:

{"A" -> "AB", "B" -> "BA"}

The multiway graph for this rule, weighted with path counts, is:

Graph[ResourceFunction["MultiwaySystem"][{"A" -> "B", "B" -> "AB"}, "AB", 4, "StatesGraph", "IncludeStatePathWeights" -> True], VertexLabels -> "VertexWeight", AspectRatio -> 1/2]

The corresponding weighted branchial graphs are:

WeightedBranchialGraph[rule_, init_, t_, mult_ : 1, labs_ : True] := WeightedBranchial[ Graph[ResourceFunction["MultiwaySystem"][rule, init, t, "BranchialGraphStructure", "IncludeStatePathWeights" -> True], If[labs, VertexLabels -> "VertexWeight", {}]], mult]; WeightedBranchial[g_, mult_ : 12] := With[{cc = AnnotationValue[g, VertexWeight]}, Graph[g, VertexStyle -> Red, VertexSize -> Thread[VertexList[g] -> mult*(cc/Sqrt[Total[cc^2]])]]]; Table[WeightedBranchialGraph[{"A" -> "B", "B" -> "AB"}, "AB", t, {.2, .6, 1, 2, 3, 5}[[t - 1]], t <= 5], {t, 2, 7}]

The weights in effect define a measure on the branchial graph. A case with a particular straightforward limiting measure is the rule:

{"A" -> "AB"}

With initial condition A this gives weights that reproduce Pascal’s triangle, and yield a limiting Gaussian:

Graph[ResourceFunction["MultiwaySystem"][{"A" -> "AB"}, "AA", 4, "EvolutionGraphFull", "IncludeStatePathWeights" -> True], VertexLabels -> "VertexWeight"]

With initial condition AAA, the weights in the branchial graph limit to a 2D Gaussian:

WeightedBranchialGraph[rule_, init_, t_, mult_ : 1, labs_ : True] := WeightedBranchial[ Graph[ResourceFunction["MultiwaySystem"][rule, init, t, "BranchialGraphStructure", "IncludeStatePathWeights" -> True], If[labs, VertexLabels -> "VertexWeight", {}]], mult]; WeightedBranchial[g_, mult_ : 12] := With[{cc = AnnotationValue[g, VertexWeight]}, Graph[g, VertexStyle -> Red, VertexSize -> Thread[VertexList[g] -> mult*(cc/Sqrt[Total[cc^2]])]]]; WeightedBranchialGraph[{"A" -> "AB"}, "AAA", 9, 5]

In general, after sufficiently many steps one can expect that the weights will define an invariant measure, although a complexity is that the branchial graph will typically continue to grow. As one indication of the limiting measure, one can compute the distribution of values of the weights.

The results for the rule {A B, B AB} above illustrate slow convergence to a limiting form:

CloudGet["https://wolfr.am/Llfn2I1P"]

We discussed in a previous subsection probing the structure of the branchial graph by computing the number of nodes Bb at most graph distance b from a given point. We can now generalize this to computing a path-weighted quantity (cf. [1:p959]). At least for simple multiway graphs, this may be related in the limit to the results of solving a PDE on the multiway graph.