So I'm very (very, very) new to Mathematica. I have a 3D graph (generated with Graph3D from a graph generated by WeightedAdjacencyGraph) and I would like to use edge weights from the original, 2D weighted graph to set the thickness of the edges on the 3D graph. I'm aware that I can use EdgeShapeFunction -> (Tube[#, radius] &) with some preset radius to make all of the edges have some thickness, but I can't figure out how to (or if it's possible to) make the edges have differing thicknesses.

  • $\begingroup$ I believe I already described everything you need in the link above, both with pure Mathematica and IGraph/M. You need to set a different EdgeShapeFunction for each edge. Probably the most compact way is with IGraph/M, IGEdgeMap[ Function[weight, {CapForm["Rounded"], Tube[#, 0.1 weight]} &], EdgeShapeFunction -> IGEdgeProp[EdgeWeight], g ] $\endgroup$
    – Szabolcs
    Commented Jun 6, 2017 at 15:23

1 Answer 1

myEdges = {1 <-> 2, 2 <-> 3, 3 <-> 1};

myEdgeWeights = {.01, .02, .03};

myAssociation = AssociationThread[Sort /@ myEdges -> myEdgeWeights];

 EdgeShapeFunction -> ({Tube[{First[#1], Last[#1]}, myAssociation@Sort[#2]]} &)]

enter image description here

  • 1
    $\begingroup$ What about doing it in 3D? $\endgroup$
    – Szabolcs
    Commented Jun 6, 2017 at 15:14
  • $\begingroup$ The issue is that a) that's 2D, I need to do it in 3D, and b) I can't set the thicknesses manually like that, they need to be automatically extracted from the edge weights (because the edge weights change every time I run my code, it's non-deterministic). $\endgroup$
    – Harper
    Commented Jun 6, 2017 at 15:16
  • $\begingroup$ OK... I'm on it... just a few minutes... $\endgroup$ Commented Jun 6, 2017 at 15:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.