Hi Hyemin,

The method does divide the count by the number of shortest paths.

Best,

Tore

I have a question for the Betweenness centrality. You counted only ‘ the number of shortest paths that pass through a certain node ‘, unlike what you proposed in your paper. Is there any special reason that you didn’t make the tnet function in this way? Why didn’t you divide it by the total number of the shortest path? If the it is divided, this weighted betweenness centrality would also mean the rate of the shortest path that pass the certain node among the whole shortest path, just like the Freeman’s one.

What I am trying to do through tnet is to compare the results measured by freeman’s BC and your BC, to see how the network analysis result varies when reflecting edge weights.

I would really love to hear your answer.

Best,

Hyemin

Hi Yingjie,

tnet is not able to handle missing values in the edgelist. I don’t know if a good way of dealing with missing data when computing network metrics. If you remove these, do you get the same error message?

Best,

Tore

Great work. Thanks for your contributions! I got the following error message when computing centrality scores (degree and closeness) and would very much appreciate any ideas on how to solve it:

Error in as.tnet(net, type = “weighted one-mode tnet”):

There are duplicated entries in the edgelist

This error occurred to all team networks with missing edge values (in these cases one or two nodes did not respond). And there are no multiple ties between nodes.

I feel it might have something to do with missing edge values. But do you have an answer to this?

Thanks a lot!

Yingjie

Hi Luke,

The tie weights come into consideration when identifying the shortest path. In a weighted network, this is the path with the smallest sum of tie weights between two nodes. When computing betweenness, all the nodes on the path between the two nodes with the smallest sum of tie weights gets 1 added to their betweenness score.

Good luck!

Tore

Thanks so much for this. I’m trying to understand how calculating the betweenness for a node works in a weighted graph where we only care about edge weights (i.e. alpha = 1). Where does the distance between two nodes come into play, especially if you have one shortest path between two nodes and that path goes through the node you’re measuring betweenness for. Doesn’t the exponential approach still just leave you with a betweenness of 1? I feel like I’m missing something.

Thanks!

Luke

Thanks! Tore!

]]>Hi Ana. Your network is a tree, and as such, there aren’t multiple paths between nodes. The weighted versions of betweenness requires this to produce a different result than the binary one. Have a look at the figure with three paths between nodes A and B (Figure 3 in the paper).

Best,

Tore

Thanks for the replay!

I that case, I don’t understand how alpha could control the paths being chosen as the shortest, since the shortest path is only one in a network.

Thanks again!

Ana

]]>The alpha simply controls the paths being chosen as the shortest. It does not increase the betweenness score. Betweenness is defined as the count of paths that go through a node. This is in contrast to closeness where the metric is the sum of inverse weights.

Best,

Tore

Thanks Tore!

But look at the nodes 4 and 5. Both participate in 4 shortest path:

4 in 1->2->4->8; 2->4->8; 1->2->4->9; 2->4->9

5 in 1->2->5->10; 2->5->10; 1->2->5->11; 2->5->11

When weights are not considered both have betweenness = 4.

However, when weights are considered (alpha >0) I will expect that node 4 would have higher betweenness than node 5, since node 4 has more weight in one path. So I think, I am not understanding how the weights are playing!

Thanks!

Ana

Hi Ana,

The network is very simply and contain few triads (e.g., 2->5->11) which would increase the intermediary node’s score by 1. The alpha parameter simply changes which paths are taken. Please see the paper.

Good luck with your work.

Tore

]]>I have two problems.

1) I am trying to estimate betweenness_w in a directed and weighted graph. However, when I change alpha to 0 or 1 the results is the same. For example:

## This is the net:

m.tnet

i j w

1 2 2

1 3 4

2 4 2

2 5 1

3 6 2

3 7 1

4 8 3

4 9 4

5 10 3

5 11 4

## Result 1:

betweenness_w(m.tnet,alpha=0)

node betweenness

[1,] 1 0

[2,] 2 6

[3,] 3 2

[4,] 4 4

[5,] 5 4

[6,] 6 0

[7,] 7 0

[8,] 8 0

[9,] 9 0

[10,] 10 0

[11,] 11 0

## Result 2:

betweenness_w(m.tnet,alpha=1)

node betweenness

[1,] 1 0

[2,] 2 6

[3,] 3 2

[4,] 4 4

[5,] 5 4

[6,] 6 0

[7,] 7 0

[8,] 8 0

[9,] 9 0

[10,] 10 0

[11,] 11 0

## Result 3:

betweenness_w(m.tnet,alpha=0.5)

node betweenness

[1,] 1 0

[2,] 2 6

[3,] 3 2

[4,] 4 4

[5,] 5 4

[6,] 6 0

[7,] 7 0

[8,] 8 0

[9,] 9 0

[10,] 10 0

[11,] 11 0

It is always the same! Could you help me?

Thanks,

Ana

]]>Thanks a lot. Now I understand it. your comment was very helpful.

Best regards,

Aleksandre

]]>Hi Aleksandre,

The best way to understand the code is often to look at the implementation. I chose to write all of tnet using R code and rely on other packages for the heavier computation to increase transparency. For example, by typing closeness_w without () at the end, the underlying code will be displayed.

In your example, I have computed the distance matrix along with the row sum and inverse row sum below. Hope this explains it.

Good luck,

Tore

X1 X2 X3 rowSums invRowSums 1 NA 2.333333 1.1666667 3.500000 0.2857143 2 0.5833333 NA 0.5833333 1.166667 0.8571429 3 1.7500000 1.166667 NA 2.916667 0.3428571]]>

Thank you very much for all this valuable information. I am a biologist by training and SNA is a new field for me so just now I am in a process of finding out about all the network-wide and node specific statistical parameters. I have encountered a problem reproducing weighted closeness centrality values myself using the formula you provide in your article (Opsahl et al. 2010). E.g. if we have a very simple 3 node weighted directed graph:

linkstest <- cbind(

i=c(1,1,2,2,3,3),

j=c(2,3,1,3,1,2),

w=c(1,2,4,4,1,2))

closeness_w(linkstest, directed = T, alpha=1)

node closeness n.closeness

[1,] 1 0.2857143 0.1428571

[2,] 2 0.8571429 0.4285714

[3,] 3 0.3428571 0.1714286

Now using the formula if I want to calculate closeness e.g. for node 1, I get the weighted distance of 1/3+1/5 = 0.53 and to the power of -1 = 1.87 and I cannot understand how r calculates 0.28 for the node 1.

Could you please help me understanding the mathematics behind? am I missing something from the formula?

Thanks a lot for your help in advance.

Best regards,

Aleksandre

]]>Hi Aldo,

The closeness function (and more generally, the shortest path function) inverts tie weights so that a higher value means higher capacity. Normally in shortest path algorithms, tie weights represent cost or distance. Have a look at this page: https://toreopsahl.com/tnet/weighted-networks/shortest-paths/

Best,

Tore

Your contribution here is superb, congrats. I want to ask you about the tie weights considered as costs. what happen if the weights represent capacity or speed? I want to privilege the paths that have higher tie weights (high farness isn´t?) If I run closenness_w do I need to check the lower values to find who is central? ]]>

Hi Kamil,

I am sure there are more efficient ways of computing betweenness. I have focused more on producing a number that easily matches intuition (e.g., inverting tie weights). If you come up with a faster method, I am happy to update the way tnet computes betweenness.

Best,

Tore

I am new to the centrality measures and this post is very informative, it helped me understand in the first place. I was hoping you could help me with a problem. My work mostly focus on betweenness. I was wondering if there is a faster algorithm to calculate betweenness in weighted graphs with small number of KNOWN weights. For instance, weights of edges in my system are restricted with {1,2,3,4}. I want to calculate betweenness of each node. But there are a lot of nodes and Running time of Dijkstra’s algorithm looks unfair to me against unrestricted weighted graph. If you know a way, could you help me?

Thanks,

Kamil

Hi Helen,

I am not entirely sure about igraph — you would have to contact the guys behind it. However, I know that igraph considers a lower tie value to be stronger (tnet considers a higher tie value to be stronger). For disconnected network, I am not sure how igraph deals with it. In tnet, you can set the gconly to be FALSE to get the closeness score of disconnected nodes. See https://toreopsahl.com/2010/03/20/closeness-centrality-in-networks-with-disconnected-components/

Best,

Tore

Thanks for much for the informative blog. I was hoping you could help me with a quick question, when you are calculating closeness (in igraph) on a weighted (and directed) network, what value is returned for nodes that are not connected (equivalent to the sum of all nodes being returned in an unweighted network) or are weights rescaled such that the total number of nodes is still used?

Many thanks. Helen

]]>Hi Tobi,

The distribution of betweenness scores is often zero inflated. If there are central nodes with strong ties, they become key intermediaries among others.

If you have any questions, email me a copy of the data and the code. I will quickly check it.

Best,

Tore

I have a problem with calculating the weighted betweennes for my network and don’t understand why my output looks the way it looks. I have a complete network with 79 nodes and weighted edges with levels ranging from 0.091 to 362’923. Since it is a complete network the alpha parameter can be set to one in order to neglect the effect of multiple edges on the betweennes score (is this correct or am I wrong?). With the code betweenness_w(“network name”,directed=TRUE,alpha=1) I get the following output:

[1,] 1 0

[2,] 2 0

[3,] 3 0

[4,] 4 0

[5,] 5 0

[6,] 6 0

[7,] 7 0

[8,] 8 152

[9,] 9 0

[10,] 10 0

……

There are many zeros. Is this because of the very big difference in levels of the edges or is this related to the completeness of the network?

Thank you very much for your efforts!

best,

Tobi

Hi Justyna,

This is a hard question as closeness depends more on the ties that the nodes bring with them to the network. If a node that bridges two disconnected components, a large change can occur to the closeness metrics. Conversely, adding isolates or nodes outsides the main component will not change the closeness metric.

Best,

Tore