Message Boards Message Boards

1
|
8254 Views
|
6 Replies
|
14 Total Likes
View groups...
Share
Share this post:

Plot network with edges depending on weights?

I have the following weights and graph:

w = {2., 1., 0.5, 0.3, 1.2};
GraphPlot[{1 -> 2, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2}]

What I want is to visualize the graph in such a way that edges have a different thickness and color proportionally, depending on the weights given.

Does anyone know how to do this in Mathematica?

Thanks in advance for any help!

6 Replies

I wrote a little guide that might be useful to you: On design of styles for small weighted graphs

https://community.wolfram.com/groups/-/m/t/838652

enter image description here

POSTED BY: Vitaliy Kaurov
POSTED BY: Szabolcs Horvát

Amazing answer!

Thank you so much!

I've done some work over your code to reach this:

Networks

I hope your answer can be helpful also for other people =)

POSTED BY: Seth Chandler

I would recommend using the newer Graph method rather than the older GraphPlot. I've made up some functions for thickness and coloring. You will want to use your own.

  w = {2., 1., 0.5, 0.3, 1.2};
  g = Graph[{1 -> 2, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2}];
  styledEdges = MapThread[
   Property[#1, 
     EdgeStyle -> {Hue[LogisticSigmoid[#2]], 
       Thickness[Min[0.03, #2/100]]}] &, {EdgeList[g], w}];
 Graph[styledEdges]
POSTED BY: Seth Chandler
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract