Skip to content

Tutorial on DAG#725

Merged
ntamas merged 1 commit intoigraph:mainfrom
iosonofabio:tutorial-dag
Oct 27, 2023
Merged

Tutorial on DAG#725
ntamas merged 1 commit intoigraph:mainfrom
iosonofabio:tutorial-dag

Conversation

@iosonofabio
Copy link
Copy Markdown
Member

Taking inspiration from #724, this adds a new tutorial on directed acyclic graphs.

I thought why not.

@iosonofabio iosonofabio requested a review from ntamas October 27, 2023 07:56
@ntamas ntamas merged commit 0d4ffc3 into igraph:main Oct 27, 2023
@ntamas
Copy link
Copy Markdown
Member

ntamas commented Oct 27, 2023

Thanks!

@szhorvat
Copy link
Copy Markdown
Member

Can you change this to use the G(n,m) model and add a comment that spells out that the method samples DAGs with the same number of vertices and edges uniformly?

@szhorvat
Copy link
Copy Markdown
Member

I'll push this change soon.

But a question: Does Sugiyama not do proper edge routing in Python, like it does in R? I see results like this:

image

I am expecting something like this instead:

image

@ntamas
Copy link
Copy Markdown
Member

ntamas commented Nov 3, 2023

Does Sugiyama not do proper edge routing in Python, like it does in R?

No it doesn't. More precisely: it can be called as layout_sugiyama(), in which case it returns the layout matrix but does not return the extended graph, for sake of compatibility with other layout_...() methods that also return the layout only, or it can be called as layout_sugiyama(return_extended_graph=True), in which case it returns the extended graph with the dummy vertices and the layout, but then you need to take care of setting up the plotting so that the additional vertices are hidden and only the edges are routed between them (and even then you won't have nice curved edges).

@ntamas
Copy link
Copy Markdown
Member

ntamas commented Nov 3, 2023

Not sure what the best approach would be when dealing with this in the tutorial. Something like this should do the trick:

layout, extd_graph = g.layout("sugiyama", return_extended_graph=True)
ig.plot(
    extd_graph,
    vertex_size = [20] * g.vcount() + [0] * (extd_graph.vcount() - g.vcount())
    # the rest of arguments should be as they are in the current example
)

but then we'd still need to hide the arrowheads on all the edges that point to a dummy vertex, otherwise we end up with extra arrowheads. So it's a bit too much code for my taste for a simple tutorial example.
It shifts the focus from generating the DAG to plotting.

@szhorvat
Copy link
Copy Markdown
Member

szhorvat commented Nov 3, 2023

In C/igraph 0.11 we should develop conventions for returning edge routing information. The extended graph approach might not be the best fit for other algorithms. Once we have this in place, there can be a convention layout_ functions in Python as well. It would be nice to implement this for the new Python interface.

@iosonofabio
Copy link
Copy Markdown
Member Author

Indeed when we say "graph layout" casually we kind of mean "vertex layout", didn't think about that before.

I agree with @szhorvat that some form of support for routing would be nice to have after the refactor. That would also need a special infrastructure on the plotting side, to automate the issues highlighted above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants