如何根据 Wolfram 中的权重设置图形的边样式?

How to set edges styles of Graph based on it's weights in Wolfram?

我用 ellpollnovi 等顶点名称设置我的自定义图形(不是数字,而是符号名称)。然后我设置顶点和边的权重(权重可以是正数或负数)。我想根据这些权重设置顶点和边的不同样式参数。我怎样才能做到这一点?谢谢。

Graph[
 {
  Labeled[
   Property[
    vat, {VertexSize -> (.567 + .7)/3, 
     VertexStyle -> Hue[.567/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    elch, {VertexSize -> (-.608 + .7)/3, 
     VertexStyle -> Hue[-.608/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    ion, {VertexSize -> (-.025 + .7)/3, 
     VertexStyle -> Hue[-.025/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    kar, {VertexSize -> (-.167 + .7)/3, 
     VertexStyle -> Hue[-.167/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    kos, {VertexSize -> (-.400 + .7)/3, 
     VertexStyle -> Hue[-.400/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    lap, {VertexSize -> (.408 + .7)/3, 
     VertexStyle -> Hue[.408/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    mas, {VertexSize -> (-.050 + .7)/3, 
     VertexStyle -> Hue[-.050/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    novi, {VertexSize -> (.258 + .7)/3, 
     VertexStyle -> Hue[.258/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    novo, {VertexSize -> (-.033 + .7)/3, 
     VertexStyle -> Hue[-.033/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    pod, {VertexSize -> (-.083 + .7)/3, 
     VertexStyle -> Hue[-.083/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    pol, {VertexSize -> (.142 + .7)/3, 
     VertexStyle -> Hue[.142/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    sar, {VertexSize -> (.025 + .7)/3, 
     VertexStyle -> Hue[.025/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    sok, {VertexSize -> (-.142 + .7)/3, 
     VertexStyle -> Hue[-.142/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    sut, {VertexSize -> (.067 + .7)/3, 
     VertexStyle -> Hue[.067/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    ust, {VertexSize -> (-.050 + .7)/3, 
     VertexStyle -> Hue[-.050/3 + .75, 1, 1]}], ""],
  Labeled[
   Property[
    ell, {VertexSize -> (.117 + .7)/3, 
     VertexStyle -> Hue[.117/3 + .75, 1, 1]}], ""]
  }
 ,
 {
  Property[vat -> elch, EdgeWeight -> -9], 
  Property[vat -> kar, EdgeWeight -> 3], 
  Property[vat -> kos, EdgeWeight -> -4], 
  Property[vat -> lap, EdgeWeight -> 5], 
  Property[vat -> mas, EdgeWeight -> -1], 
  Property[vat -> novi, EdgeWeight -> 1], 
  Property[vat -> novo, EdgeWeight -> 1], 
  Property[vat -> pod, EdgeWeight -> -2], 
  Property[vat -> pol, EdgeWeight -> 4], 
  Property[vat -> sut, EdgeWeight -> 2],
  Property[kar -> vat, EdgeWeight -> 9], 
  Property[kar -> elch, EdgeWeight -> -9], 
  Property[kar -> ion, EdgeWeight -> -1], 
  Property[kar -> lap, EdgeWeight -> 1], 
  Property[kar -> mas, EdgeWeight -> -2], 
  Property[kar -> novi, EdgeWeight -> 4], 
  Property[kar -> novo, EdgeWeight -> 1], 
  Property[kar -> sar, EdgeWeight -> 1], 
  Property[kar -> sok, EdgeWeight -> -4], 
  Property[kar -> ust, EdgeWeight -> -2],
  Property[sok -> vat, EdgeWeight -> 2], 
  Property[sok -> elch, EdgeWeight -> -4], 
  Property[sok -> ion, EdgeWeight -> -3], 
  Property[sok -> kar, EdgeWeight -> -4], 
  Property[sok -> kos, EdgeWeight -> -3], 
  Property[sok -> lap, EdgeWeight -> 3], 
  Property[sok -> novi, EdgeWeight -> 1], 
  Property[sok -> novo, EdgeWeight -> 1], 
  Property[sok -> pod, EdgeWeight -> -1], 
  Property[sok -> pol, EdgeWeight -> -3], 
  Property[sok -> sar, EdgeWeight -> 2], 
  Property[sok -> sut, EdgeWeight -> 2], 
  Property[sok -> ell, EdgeWeight -> 7],
  Property[novo -> vat, EdgeWeight -> 6], 
  Property[novo -> elch, EdgeWeight -> 3], 
  Property[novo -> ion, EdgeWeight -> -2], 
  Property[novo -> kar, EdgeWeight -> -2], 
  Property[novo -> kos, EdgeWeight -> -3], 
  Property[novo -> lap, EdgeWeight -> 1], 
  Property[novo -> pod, EdgeWeight -> -1], 
  Property[novo -> sok, EdgeWeight -> -2], 
  Property[novo -> sut, EdgeWeight -> 1], 
  Property[novo -> ust, EdgeWeight -> -3], 
  Property[novo -> ell, EdgeWeight -> 2],
  Property[sut -> vat, EdgeWeight -> 7], 
  Property[sut -> elch, EdgeWeight -> -3], 
  Property[sut -> kar, EdgeWeight -> -6], 
  Property[sut -> kos, EdgeWeight -> -6], 
  Property[sut -> lap, EdgeWeight -> -1], 
  Property[sut -> novi, EdgeWeight -> 6], 
  Property[sut -> novo, EdgeWeight -> -1], 
  Property[sut -> pol, EdgeWeight -> 4],
  Property[novi -> vat, EdgeWeight -> 3], 
  Property[novi -> elch, EdgeWeight -> -3], 
  Property[novi -> kar, EdgeWeight -> 2], 
  Property[novi -> kos, EdgeWeight -> -7], 
  Property[novi -> lap, EdgeWeight -> 6], 
  Property[novi -> mas, EdgeWeight -> 1], 
  Property[novi -> novo, EdgeWeight -> -1], 
  Property[novi -> pol, EdgeWeight -> 3], 
  Property[novi -> sut, EdgeWeight -> -2], 
  Property[novi -> ust, EdgeWeight -> -1], 
  Property[novi -> ell, EdgeWeight -> 3],
  Property[lap -> vat, EdgeWeight -> 8], 
  Property[lap -> elch, EdgeWeight -> -2], 
  Property[lap -> ion, EdgeWeight -> 1], 
  Property[lap -> kar, EdgeWeight -> 1], 
  Property[lap -> kos, EdgeWeight -> -3], 
  Property[lap -> mas, EdgeWeight -> -3], 
  Property[lap -> novi, EdgeWeight -> 4], 
  Property[lap -> novo, EdgeWeight -> -1], 
  Property[lap -> sar, EdgeWeight -> -4], 
  Property[lap -> sok, EdgeWeight -> -2], 
  Property[lap -> ell, EdgeWeight -> 1],
  Property[ell -> vat, EdgeWeight -> 3], 
  Property[ell -> elch, EdgeWeight -> -8], 
  Property[ell -> kar, EdgeWeight -> 1], 
  Property[ell -> kos, EdgeWeight -> -2], 
  Property[ell -> lap, EdgeWeight -> 6], 
  Property[ell -> mas, EdgeWeight -> -3], 
  Property[ell -> novi, EdgeWeight -> 1], 
  Property[ell -> novo, EdgeWeight -> -2], 
  Property[ell -> pol, EdgeWeight -> 5], 
  Property[ell -> sok, EdgeWeight -> -3], 
  Property[ell -> sut, EdgeWeight -> 2],
  Property[ust -> vat, EdgeWeight -> 6], 
  Property[ust -> elch, EdgeWeight -> -8], 
  Property[ust -> ion, EdgeWeight -> 2], 
  Property[ust -> kos, EdgeWeight -> -7], 
  Property[ust -> lap, EdgeWeight -> 2], 
  Property[ust -> novi, EdgeWeight -> 2], 
  Property[ust -> pod, EdgeWeight -> 1], 
  Property[ust -> pol, EdgeWeight -> 2], 
  Property[ust -> sok, EdgeWeight -> -2], 
  Property[ust -> sut, EdgeWeight -> 2],
  Property[mas -> vat, EdgeWeight -> 3], 
  Property[mas -> elch, EdgeWeight -> -9], 
  Property[mas -> kar, EdgeWeight -> -2], 
  Property[mas -> kos, EdgeWeight -> -5], 
  Property[mas -> lap, EdgeWeight -> 8], 
  Property[mas -> novi, EdgeWeight -> 1], 
  Property[mas -> pod, EdgeWeight -> -2], 
  Property[mas -> pol, EdgeWeight -> 1], 
  Property[mas -> sar, EdgeWeight -> 4], 
  Property[mas -> ell, EdgeWeight -> 1],
  Property[sar -> vat, EdgeWeight -> 5], 
  Property[sar -> elch, EdgeWeight -> -7], 
  Property[sar -> kar, EdgeWeight -> -3], 
  Property[sar -> kos, EdgeWeight -> -4], 
  Property[sar -> lap, EdgeWeight -> 8], 
  Property[sar -> mas, EdgeWeight -> 2], 
  Property[sar -> novi, EdgeWeight -> 3], 
  Property[sar -> pod, EdgeWeight -> -4],
  Property[ion -> vat, EdgeWeight -> 9], 
  Property[ion -> elch, EdgeWeight -> -1], 
  Property[ion -> kar, EdgeWeight -> -9], 
  Property[ion -> kos, EdgeWeight -> -4], 
  Property[ion -> lap, EdgeWeight -> 6], 
  Property[ion -> novi, EdgeWeight -> 2], 
  Property[ion -> novo, EdgeWeight -> -1], 
  Property[ion -> pod, EdgeWeight -> -1], 
  Property[ion -> pol, EdgeWeight -> 1], 
  Property[ion -> sok, EdgeWeight -> -2],
  Property[pod -> vat, EdgeWeight -> 7], 
  Property[pod -> elch, EdgeWeight -> -9], 
  Property[pod -> ion, EdgeWeight -> -2], 
  Property[pod -> kar, EdgeWeight -> -1], 
  Property[pod -> lap, EdgeWeight -> 4], 
  Property[pod -> novi, EdgeWeight -> 6], 
  Property[pod -> novo, EdgeWeight -> -1], 
  Property[pod -> sok, EdgeWeight -> -2], 
  Property[pod -> sut, EdgeWeight -> 1]
  },
 EdgeShapeFunction -> 
  GraphElementData[{"CarvedArrow", "ArrowSize" -> .01}],
  GraphLayout -> "CircularEmbedding",
 EdgeStyle -> 
  Thread[a -> 
    Transpose@{Dashing /@ ((b + 0.5)/10), Hue /@ (b + 0.5), 
      Thickness /@ ((b + 0.5)/100)}]
 ]

您没有提供太多关于图表的信息,但这是一种让 EdgeWeight 定义不同 EdgeStyle 特征的方法。

Graph[a = {"a" <-> "b", "b" <-> "c", "c" <-> "a"}, 
 EdgeWeight -> (b = RandomReal[{-.5, .5}, 3]), 
 EdgeStyle -> 
  Thread[a -> 
    Transpose@{Dashing /@ ((b + 0.5)/10), Hue /@ (b + 0.5), 
      Thickness /@ ((b + 0.5)/100)}]]

编辑:

name = {vat, elch, ion, kar, kos, lap, mas, novi, novo, pod, pol, sar,
    sok, sut, ust, ell};
vSize = {.567, -.608, -.025, -.167, -.4, .408, -.05, .258, -.033, \
-.083, .142, .025, -.142, .067, -.05, .117};
hue = {.567, -.608, -.025, -.167, -.4, .408, -.05, .258, -.033, \
-.083, .172, .025, -.142, .025, -.142, .067, -.050, .117};
props = Labeled[
     Property[
      name[[#]], {VertexSize -> (vSize[[#]] + .7)/3, 
       VertexStyle -> Hue[hue[[#]]/3 + .75, 1, 1]}], ""] & /@ 
   Range[Length[name]];
a = {vat -> elch, vat -> kar, vat -> kos, vat -> lap, vat -> mas, 
   vat -> novi, vat -> novo, vat -> pod, vat -> pol, vat -> sut, 
   kar -> vat, kar -> elch, kar -> ion, kar -> lap, kar -> mas, 
   kar -> novi, kar -> novo, kar -> sar, kar -> sok, kar -> ust, 
   sok -> vat, sok -> elch, sok -> ion, sok -> kar, sok -> kos, 
   sok -> lap, sok -> novi, sok -> novo, sok -> pod, sok -> pol, 
   sok -> sar, sok -> sut, sok -> ell, novo -> vat, novo -> elch, 
   novo -> ion, novo -> kar, novo -> kos, novo -> lap, novo -> pod, 
   novo -> sok, novo -> sut, novo -> ust, novo -> ell, sut -> vat, 
   sut -> elch, sut -> kar, sut -> kos, sut -> lap, sut -> novi, 
   sut -> novo, sut -> pol, novi -> vat, novi -> elch, novi -> kar, 
   novi -> kos, novi -> lap, novi -> mas, novi -> novo, novi -> pol, 
   novi -> sut, novi -> ust, novi -> ell, lap -> vat, lap -> elch, 
   lap -> ion, lap -> kar, lap -> kos, lap -> mas, lap -> novi, 
   lap -> novo, lap -> sar, lap -> sok, lap -> ell, ell -> vat, 
   ell -> elch, ell -> kar, ell -> kos, ell -> lap, ell -> mas, 
   ell -> novi, ell -> novo, ell -> pol, ell -> sok, ell -> sut, 
   ust -> vat, ust -> elch, ust -> ion, ust -> kos, ust -> lap, 
   ust -> novi, ust -> pod, ust -> pol, ust -> sok, ust -> sut, 
   mas -> vat, mas -> elch, mas -> kar, mas -> kos, mas -> lap, 
   mas -> novi, mas -> pod, mas -> pol, mas -> sar, mas -> ell, 
   sar -> vat, sar -> elch, sar -> kar, sar -> kos, sar -> lap, 
   sar -> mas, sar -> novi, sar -> pod, ion -> vat, ion -> elch, 
   ion -> kar, ion -> kos, ion -> lap, ion -> novi, ion -> novo, 
   ion -> pod, ion -> pol, ion -> sok, pod -> vat, pod -> elch, 
   pod -> ion, pod -> kar, pod -> lap, pod -> novi, pod -> novo, 
   pod -> sok, pod -> sut};
b = {-9, 3, -4, 5, -1, 1, 1, -2, 4, 2, 9, -9, -1, 1, -2, 4, 1, 
   1, -4, -2, 2, -4, -3, -4, -3, 3, 1, 1, -1, -3, 2, 2, 7, 6, 
   3, -2, -2, -3, 1, -1, -2, 1, -3, 2, 7, -3, -6, -6, -1, 6, -1, 4, 
   3, -3, 2, -7, 6, 1, -1, 3, -2, -1, 3, 8, -2, 1, 1, -3, -3, 
   4, -1, -4, -2, 1, 3, -8, 1, -2, 6, -3, 1, -2, 5, -3, 2, 6, -8, 
   2, -7, 2, 2, 1, 2, -2, 2, 3, -9, -2, -5, 8, 1, -2, 1, 4, 1, 
   5, -7, -3, -4, 8, 2, 3, -4, 9, -1, -9, -4, 6, 2, -1, -1, 1, -2, 
   7, -9, -2, -1, 4, 6, -1, -2, 1};
Graph[props, a, EdgeWeight -> b, 
 EdgeShapeFunction -> 
  GraphElementData[{"CarvedArrow", "ArrowSize" -> .01}], 
 GraphLayout -> "CircularEmbedding", 
 EdgeStyle -> 
  Thread[a -> 
    Transpose@{Dashing /@ ((b + 9)/2000), Hue /@ ((b + 9)/20), 
      Thickness /@ ((b + 9)/2000)}]]