CNum = 5;
PNum = 10;
lis1 = Flatten@
Table[Thread[
Subscript[t, n] -> Array[Subscript[c, n, #] &, PNum]], {n,
CNum}];
lis2 = Flatten[
Outer[Rule, Sequence @@ #] & /@
Partition[Table[Array[Subscript[c, n, #] &, PNum], {n, CNum}], 2,
1]];
lis = Join[lis1, lis2];
g = Graph[lis, VertexLabels -> "Name",
GraphLayout -> "LayeredDigraphEmbedding",
GraphHighlight -> {Subscript[c, 1, 2] -> Subscript[c, 2, 9],
Subscript[c, 2, 9] -> Subscript[c, 3, 3],
Subscript[c, 3, 3] -> Subscript[c, 4, 5],
Subscript[c, 4, 5] -> Subscript[c, 5, 2]},
GraphHighlightStyle -> "Thick",
EdgeWeight -> RandomReal[1, Length@lis]]

我现在想求的是从 "c_ (1, 几)" 走到 "c_ (CNum, 几)", 并使得两种cost的计算的和最小
举了例子就是从c_ (1, 2) ->
c_ (2, 9) -> ... -> c_ (5, 2)。并且使得这个距离:cost1 (红色线条距离的和) +
(t1 -> c_ (1, 2)) +
(t2 -> c_ (2, 9)) + ... + +(t5 ->
c_ (5, 2)) 的距离最短 \
但是看起来FindShortestPath好像不能解决这个问题,因为不是单纯点到点的距离而是某一段到某一段的距离的距离最小
这个可以用Mathematica解决吗?
PNum = 10;
lis1 = Flatten@
Table[Thread[
Subscript[t, n] -> Array[Subscript[c, n, #] &, PNum]], {n,
CNum}];
lis2 = Flatten[
Outer[Rule, Sequence @@ #] & /@
Partition[Table[Array[Subscript[c, n, #] &, PNum], {n, CNum}], 2,
1]];
lis = Join[lis1, lis2];
g = Graph[lis, VertexLabels -> "Name",
GraphLayout -> "LayeredDigraphEmbedding",
GraphHighlight -> {Subscript[c, 1, 2] -> Subscript[c, 2, 9],
Subscript[c, 2, 9] -> Subscript[c, 3, 3],
Subscript[c, 3, 3] -> Subscript[c, 4, 5],
Subscript[c, 4, 5] -> Subscript[c, 5, 2]},
GraphHighlightStyle -> "Thick",
EdgeWeight -> RandomReal[1, Length@lis]]

我现在想求的是从 "c_ (1, 几)" 走到 "c_ (CNum, 几)", 并使得两种cost的计算的和最小
举了例子就是从c_ (1, 2) ->
c_ (2, 9) -> ... -> c_ (5, 2)。并且使得这个距离:cost1 (红色线条距离的和) +
(t1 -> c_ (1, 2)) +
(t2 -> c_ (2, 9)) + ... + +(t5 ->
c_ (5, 2)) 的距离最短 \
但是看起来FindShortestPath好像不能解决这个问题,因为不是单纯点到点的距离而是某一段到某一段的距离的距离最小
这个可以用Mathematica解决吗?