# How can I get all options of a function from IGraphM?

**URL:** <https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131>\
**Category:** Usage\
**Tags:** Mathematica\
**Created:** [17 May 2025 10:43 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131 "2025-05-17T10:43:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anhnha](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/anhnha/32/1169_2.png) [@anhnha](https://igraph.discourse.group/u/anhnha)\
**Post date:** [17 May 2025 10:43 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131/1 "2025-05-17T10:43:58Z")

</div>

How can I get all options of a function from IGraphM?  
For example, I want to retrieve the options for the function `IGLayoutPlanar`, but `Options[IGLayoutPlanar]` returns an empty list `{}`, even though I believe it does have some options. The documentation also doesn’t mention any options for this function.

This seems to apply to other functions in **IGraphM** as well. I suppose I could check the source code directly, but that’s a bit inconvenient.

 ![image](https://global.discourse-cdn.com/free1/uploads/igraph/original/2X/9/946ec66475d0af3b5b63cf9ddd9a2e2559e017a0.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/igraph/original/2X/9/998ce184772536a5e002784219e04acbca5f770f.jpeg)

**Another question related to `IGLayoutPlanar`:**  
It seems to only work with simple graphs. Is there a way to make it work with **multigraphs**?  
I’d like to display all parallel edges and show their labels as well.

---

<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:** [18 May 2025 10:45 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131/2 "2025-05-18T10:45:19Z")

</div>

Options: `IGLayoutPlanar` takes all options that `Graph` does and passes them on to `Graph`. This should be the case with all IGraph/M functions that produce a `Graph` expression. With the current design, only those options would appear in `Options[IGLayoutPlanar]` that are specific to `IGLayoutPlanar`, and there are no options like this at the moment.

> [@anhnha](#):
>
> It seems to only work with simple graphs. Is there a way to make it work with **multigraphs**?

The algorithm used here only produces vertex coordinates, not edge routing information. The vertex coordinates are chosen in such a way that straight-line edges would not intersect. Theoretically, with multigraphs, straight edges could be replaced with slightly curved ones, while avoiding intersections. But an infinitesimal separation between edges is not practically useful.

To be honest, I don’t think this layout is very useful in general, and the same applies to Mathematica’s built in planar layout. These layouts prove the points that intersections can be avoided, but they do not produce very readable figures, The Tutte layout is much better for that, but it only works for 3-vertex-connected graphs. If you have the time to work on extending the Tutte layout to more cases, that would be very welcome. I believe this is possible to some extent, but probably not easy.

If you want to extend this layout to a more practical multigraph one, you could subdivide each edge, re-do the layout, then use the coordinated of the dividing vertices to guide a `BezierCurve`. This is very straightforward, but it does take some amount of programming.

Since edge subdivision comes up so frequently, it would probably make sense to add a helper function to IGraph/M that does this.

I’m travelling at the moment, and unfortunately don’t have the time to implement a proof-of-concept of the subdivision idea. If you end up doing this, please post on this forum and show us what you got 🙂

---

<div class="post-metadata">

**Author:** ![anhnha](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/anhnha/32/1169_2.png) [@anhnha](https://igraph.discourse.group/u/anhnha)\
**Post date:** [19 May 2025 06:35 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131/3 "2025-05-19T06:35:42Z")

</div>

Thank you for the detailed answer.  
I can do the subdivision and get the coordinates.  
However, I’m not quite sure how to use `BezierCurve`.  
For example, if the original edge is from _a_ to _b_, then after subdivision, it becomes _a_ ↔ _mid_ and _mid_ ↔ _b_.  
I can get the coordinates of _a_, _b_, and _mid_ from the planar layout,  
and then replot each edge using `BezierCurve` with those coordinates.  
I’ll give it a try and post the results sometime this week.

---

<div class="post-metadata">

**Author:** ![anhnha](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/anhnha/32/1169_2.png) [@anhnha](https://igraph.discourse.group/u/anhnha)\
**Post date:** [22 May 2025 02:03 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131/4 "2025-05-22T02:03:59Z")

</div>

This is my attempt based on the guide. It seems to work, but it’s a bit messy though.

```auto
ClearAll[myIGLayoutPlanar];
Options[myIGLayoutPlanar]=Options[Graph];
myIGLayoutPlanar[g_Graph,opts:OptionsPattern[]]:=Module[{g1,rule,mapping, newEdges,subdivideg,glayout,coords,coorToEdge, bezieredge},

g1=EdgeTaggedGraph[g];
(* subdivide *)
rule= {
DirectedEdge[u_, v_, l_] /; u =!= v :> With[{m = Unique[x]}, {DirectedEdge[u, m], DirectedEdge[m, v]}],
UndirectedEdge[u_, v_, l_] /; u =!= v :> With[{m = Unique[x]}, {UndirectedEdge[u, m], UndirectedEdge[m, v]}],
DirectedEdge[u_, u_, l_] :> With[{m = Unique[x], n = Unique[x]}, {DirectedEdge[u, m], DirectedEdge[m, n], DirectedEdge[n, u]}],
UndirectedEdge[u_, u_, l_] :> With[{m = Unique[x], n = Unique[x]}, {UndirectedEdge[u, m], UndirectedEdge[m, n], UndirectedEdge[n, u]}] };

mapping =#->(#/.rule)&/@ EdgeList[g1] ;

newEdges=EdgeList[g1]/.mapping//Flatten;

subdivideg=Graph[Flatten[newEdges]];

glayout= IGLayoutPlanar[subdivideg];

(* get the coordinates *) 
coords=Thread[VertexList[glayout]->GraphEmbedding@glayout];

bezieredge[pts_,edge_]:=If[Head[edge]===UndirectedEdge, BezierCurve[Flatten[List@@@(edge/.mapping),1]/.coords],Arrow@BezierCurve[Flatten[List@@@(edge/.mapping),1]/.coords]];

EdgeTaggedGraph[EdgeList[g1], VertexCoordinates->(VertexList[g1]/.coords),EdgeShapeFunction->bezieredge, EdgeLabels->"EdgeTag", PerformanceGoal -> "Quality"]
];

```

Test with undirected or directed multigraphs:

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

---

<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 2025 17:07 UTC](https://igraph.discourse.group/t/how-can-i-get-all-options-of-a-function-from-igraphm/2131/5 "2025-05-22T17:07:15Z")

</div>

Looks pretty cool, thanks for sharing the code! I’m excited to play with the code, but I’m swamped for another week.
