# Get parts of the transitivity ratio

**URL:** https://igraph.discourse.group/t/get-parts-of-the-transitivity-ratio/2243
**Category:** Usage
**Tags:** R
**Created:** [21 May 2026 17:51 UTC](https://igraph.discourse.group/t/get-parts-of-the-transitivity-ratio/2243 "2026-05-21T17:51:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Zilch](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@Zilch](https://igraph.discourse.group/u/Zilch)
#### Post date: [21 May 2026 17:51 UTC](https://igraph.discourse.group/t/get-parts-of-the-transitivity-ratio/2243/1 "2026-05-21T17:51:52Z")

</div>

Hi there. I’m trying to get both parts of the transitivity ratio, i.e. number:number, instead the 0-1 value. I tried using the triangles and graph.motifs.no function for motifs of triads but the code under provides results that are different from the transitivity function.

```auto
(length(triangles(exampleNet))/3)/graph.motifs.no(exampleNet, size=3))

```

For context I’m doing this because I would like to fit a binomial model to these results, so I need both parts of the ratio. Any help would be much appreciated.

---

<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: [22 May 2026 10:17 UTC](https://igraph.discourse.group/t/get-parts-of-the-transitivity-ratio/2243/2 "2026-05-22T10:17:45Z")

</div>

The next major version of igraph will make it easy for you to get both parts of the ratio with different functions. This is already implemented in C and released with C/igraph 1.0, but it hasn’t made its way to R yet.

What you are trying to do is a fine workaround in the meantime, but it is not quite correct. You are calculating the fraction of _unordered_ connected triplets that are closed. The global clustering coefficient, or global transitivity, is the fraction of _ordered_ connected triplets that are closed.

Have a look at the explanation I wrote up here:

[https://szhorvat.net/mathematica/IGDocumentation/#igglobalclusteringcoefficient](https://szhorvat.net/mathematica/IGDocumentation/#igglobalclusteringcoefficient)

Here’s what you can do:

```r
> g<-sample_gnm(20,50)
> mot<-motifs(g,3)
> mot
[1] NA NA 180 16

```

This tells us that there are 180 unordered triples with a connectivity pattern `1-2-3` (wedge) and 16 with the connectivity pattern `1-2-3-1` (fully closed triangles).

This is what you calculated:

```r
> mot[4] / (mot[3] + mot[4])
[1] 0.08163265

```

But every triangle contains three wedges. The triangle `1-2-3-1` contains the wedges `1-2-3`, `2-3-1`, `3-1-2`. So this is what you need:

```r
> 3*mot[4] / (mot[3] + 3*mot[4])
[1] 0.2105263
> transitivity(g, 'global')
[1] 0.2105263
> 

```

Alternatively, you can think of this more simply as each triangle contains 6 ordered wedges (all 6 permutations) and every wedge has 2 orderings (`1-2-3` and `3-2-1`).

I hope this helps.

---

<div class="post-metadata">

### Author: ![Zilch](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@Zilch](https://igraph.discourse.group/u/Zilch)
#### Post date: [2 June 2026 16:38 UTC](https://igraph.discourse.group/t/get-parts-of-the-transitivity-ratio/2243/3 "2026-06-02T16:38:19Z")

</div>

Excellent, thank you, and very glad to hear about the new functionality and looking forward to it in R.
