0
$\begingroup$

This question already has an answer here:

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.

$\endgroup$

marked as duplicate by Szabolcs, Community Jun 6 '17 at 15:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\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 Jun 6 '17 at 15:23
0
$\begingroup$
myEdges = {1 <-> 2, 2 <-> 3, 3 <-> 1};

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

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

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

enter image description here

$\endgroup$
  • $\begingroup$ What about doing it in 3D? $\endgroup$ – Szabolcs Jun 6 '17 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 Jun 6 '17 at 15:16
  • $\begingroup$ OK... I'm on it... just a few minutes... $\endgroup$ – David G. Stork Jun 6 '17 at 15:16

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