# Get triad subgraphs

**URL:** <https://igraph.discourse.group/t/get-triad-subgraphs/1503>\
**Category:** Usage\
**Tags:** Python\
**Created:** [14 March 2023 04:53 UTC](https://igraph.discourse.group/t/get-triad-subgraphs/1503 "2023-03-14T04:53:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doubledotball](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@doubledotball](https://igraph.discourse.group/u/doubledotball)\
**Post date:** [14 March 2023 04:53 UTC](https://igraph.discourse.group/t/get-triad-subgraphs/1503/1 "2023-03-14T04:53:40Z")

</div>

Hi,  
I note that python-igraph has the method Graph.triad\_census, which returns the count of each triad type in a graph.  
I haven’t been able to find a method in igraph which gives all the actual subgraphs (edges & vertices) of each triad type. If it does not exist, are there any plans for future inclusion of such a method?

At the moment we are using NetworkX’s ‘triads\_by\_type’ method, which gives quite satisfactory output, however we are looking for an increase in performance.

Thank you!

---

<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:** [14 March 2023 11:43 UTC](https://igraph.discourse.group/t/get-triad-subgraphs/1503/2 "2023-03-14T11:43:51Z")

</div>

It is possible for the _connected_ triads.

The [`motifs_randesu()`](https://python.igraph.org/en/stable/api/igraph.GraphBase.html#motifs_randesu) function has a `callback` parameter. Here you can pass a function which will be called with each triad found, and its type (“isoclass”).

---

<div class="post-metadata">

**Author:** ![doubledotball](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@doubledotball](https://igraph.discourse.group/u/doubledotball)\
**Post date:** [14 March 2023 23:27 UTC](https://igraph.discourse.group/t/get-triad-subgraphs/1503/3 "2023-03-14T23:27:55Z")

</div>

Thank you! Much appreciated.
