# Radius of nodes in igraph degree()

**URL:** <https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471>\
**Category:** Usage\
**Tags:** R\
**Created:** [7 October 2020 12:36 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471 "2020-10-07T12:36:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evaristo](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@Evaristo](https://igraph.discourse.group/u/Evaristo)\
**Post date:** [7 October 2020 12:36 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/1 "2020-10-07T12:36:57Z")

</div>

Hi,

I am using the igraph package in academia and it’s great ! I have two questions regarding the radius or scaling of nodes when using degree(graph, v, mode):

Is the radius of a node simply the square root of the number of its adjacent edges, or is there more damping involved in node growth ?

Where is the radius variable implemented in the source code … can I see it ?

Thank you for helping !

Évariste

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [8 October 2020 13:41 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/2 "2020-10-08T13:41:44Z")

</div>

I’m not sure I understand the question. Can you give a specific, complete example?

The `vertex.size` option to `plot` specifies the radius of each vertex, not its area. This has nothing to do with where you are getting the sizes from (degrees or elsewhere).

The source of `plot.igraph` is here:

> <https://github.com/igraph/rigraph/blob/7c7e6f271e4fef1da08e1a74c9587640f4fa4333/R/plot.R>

---

<div class="post-metadata">

**Author:** ![Evaristo](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@Evaristo](https://igraph.discourse.group/u/Evaristo)\
**Post date:** [8 October 2020 14:04 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/3 "2020-10-08T14:04:31Z")

</div>

Thank you !

I am specifically interested in the radius, so you are getting me on the right track. I have checked the source, now, and have found in line 282 a variable that looks like the radius of a node: r \<- sqrt((cp[,1]-center[1])\*\*2 + (cp[,2]-center[2])\*\*2). What I don’t get, right now, is what the (cp[,1]-center[1])\*\*2 is all about (I am new to R). Any hints ?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [8 October 2020 14:06 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/4 "2020-10-08T14:06:59Z")

</div>

You are asking about the source code, but I still don’t understand what the specific problem is. What problem are you trying to solve? Please be specific:

- “I need to accomplish this task”
- “This is the code I tried”
- “This is what it did instead of what I needed”

---

<div class="post-metadata">

**Author:** ![Evaristo](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@Evaristo](https://igraph.discourse.group/u/Evaristo)\
**Post date:** [8 October 2020 14:11 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/5 "2020-10-08T14:11:48Z")

</div>

Oh, right. I am driven by curiosity. I have to present a plot I generated with the degree function, pretty soon, and I expect questions on how the radius of nodes is computed in quantitative terms.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [8 October 2020 14:21 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/6 "2020-10-08T14:21:29Z")

</div>

The `degree` function does not plot—it just returns the degrees of vertices. If you want to create a plot in which the radius of each vertex is proportional to its degree, you can use something like

```r
g<-erdos.renyi.game(20,20,'gnm')
plot(g, vertex.size=5*degree(g), vertex.label=NA)

```

 ![image](https://global.discourse-cdn.com/free1/uploads/igraph/original/1X/d24af0fb5748cb5a89ac929aeb85b2c556c3ec6e.png)

Personally, I don’t often use the R interface of igraph, so I may be missing easier ways to do this. I usually work on the C core of igraph and on [IGraph/M](http://szhorvat.net/mathematica/IGraphM/).

---

<div class="post-metadata">

**Author:** ![Evaristo](https://avatars.discourse-cdn.com/v4/letter/e/f0a364/32.png) [@Evaristo](https://igraph.discourse.group/u/Evaristo)\
**Post date:** [8 October 2020 14:36 UTC](https://igraph.discourse.group/t/radius-of-nodes-in-igraph-degree/471/7 "2020-10-08T14:36:21Z")

</div>

ah, ok. Your example implies that vertex.size is not the area, but is actually the radius of a node. But, Oops, you told me that already 🙂 My wrong. This was very helpful, indeed !
