Skip to content

Conversation

@gsoleilhac
Copy link
Contributor

This makes solve_positions also return a Dict which is a mapping from edges in the original graph to paths in the graph with dummy nodes used to solve the layout problem.

The Dict has for keyset edges(g) and it's values are tuples of vectors : x and y coordinates.

I updated the examples with the output we get by plotting these paths, but the simpler examples don't look so great :

cross

src/layering.jl Outdated
Comment on lines 28 to 30
for out_node in copy(outneighbors(graph, cur_node)) # need to copy as outwise will mutate when the graph is mutated
for out_edge in filter(e -> e.src == cur_node, collect(edges(graph))) # need to copy as outwise will mutate when the graph is mutated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change from iterating the outneighbors to iterating edges to make it work with WeightedGraphs, I couldn't find how to get back to the WeightedEdge with just the src and dst vertices in a generic way. Maybe there's a better way to do it ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure. I don't know light graphs that well

Aside: Apparently the rtight way to get the soource is not e.src but rather src(e)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the collect if we are using filter as filter creates a copy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently the rtight way to get the soource is not e.src but rather src(e)

fixed

We don't need the collect if we are using filter as filter creates a copy

filter on a SimpleEdgeIter throws an MethodError, so I left the collect for now

@gsoleilhac gsoleilhac changed the title Gs/edge to path Add a mapping from edges to paths with the dummy nodes Oct 23, 2020
@@ -1,5 +1,5 @@
is_dag(g) = is_directed(g) && !is_cyclic(g)
dag_or_error(g) = is_dag(g) || DomainError(g, "Only Directed Acylic Graphs are supported")
dag_or_error(g) = is_dag(g) || throw(DomainError(g, "Only Directed Acylic Graphs are supported"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch.

@oxinabox
Copy link
Owner

Why don't we have a function solve_positions_full that returns all the points, and the full graph?
It has all the nodes of the original_graph at the original index, plus all the dummy nodes and their new edges.

then the current solve_positions would just mask-out the dummy-nodes

I don't fully understand this new structure of paths and what it is for.

@gsoleilhac
Copy link
Contributor Author

gsoleilhac commented Oct 31, 2020

Well my use case is plotting the output of some maxflow problem.
For each edge in the original graph I want to annotate the plotted edge with the flow passing through it.
If we return the full graph with the new edges, it makes it much harder to do that since I want to annotate a path in the full graph (just once) and not each edge individually.
And then, some information is lost : which edge in the full graph corresponds to which edge in the original graph ?

So that's why I went with a mapping from the edges in the original graph to paths in the full graph

@oxinabox
Copy link
Owner

Ah, I see.
This makes sense now.

Needs doc strings explaining what paths is.

@oxinabox
Copy link
Owner

oxinabox commented Nov 7, 2020

New docstring looks great.

why is CI failing?
We should have two sets of reference tests.
One set using the coordinates directly and one set using the paths.

@gsoleilhac
Copy link
Contributor Author

gsoleilhac commented Nov 8, 2020

Sure,

julia-actions/julia-uploadcoveralls fails on nightly, and that cancels the build on julia stable, but the tests pass successfuly.
Is there an allow failure option on nightly with Github CI ?

@oxinabox
Copy link
Owner

oxinabox commented Nov 8, 2020

I have added the plots to the readme.
The first one is a good demonstration of the difference this makes.

README.md Outdated
As you can see in the first plot below, pathing though the dummy nodes actually guarantees minimal number of crossings.
On the _tiny_depgaph_ example direct has 3 crossings, where as path through dummy node only 2).
However, it also doesn't actually always look as nice.
It might look as nice if you used some swishy Bezier curves though.
Copy link
Contributor Author

@gsoleilhac gsoleilhac Nov 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might look as nice if you used some swishy Bezier curves though.

I just found out that Plots exports curves, with it, the medium_pert example looks like this :

medium_pert_curved

Copy link
Owner

@oxinabox oxinabox Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Shall we change them all to use that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, it surely looks better but it doesn't help explaining what is returned in paths

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we stick a scatter plot on top with big markers dummy nodes,
or insert the letter X in place of the node name for dummy nodes?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could leave as is, maybe adding mention of the curves function in the comment in the readme?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It might look as nice if you used some swishy Bezier curves though.
It might nicer if you used some swishy Bezier curves though (Plots.jl has a [curves attribute](http://docs.juliaplots.org/latest/generated/graph_attributes/), and a matching function, which does this)

@oxinabox oxinabox closed this Nov 12, 2020
@oxinabox oxinabox reopened this Nov 12, 2020
@oxinabox oxinabox closed this Dec 29, 2020
@oxinabox oxinabox reopened this Dec 29, 2020
@oxinabox
Copy link
Owner

Sorry, I lost track of this.
I think just need to make CI pass (which might mean disabling Julia nightly)
and then we are good to merge.

Also want to decide what to do with curves.
I am now leaning towards just mentioning it in inhe README.md, so we can merge this sooner, rather than having to go through the effort of regenerating the plots.

@oxinabox oxinabox closed this Dec 29, 2020
@oxinabox oxinabox reopened this Dec 29, 2020
@oxinabox
Copy link
Owner

Rebasing this should fix the CI

@oxinabox
Copy link
Owner

oxinabox commented Feb 3, 2021

bump, this would be good to have

@gsoleilhac
Copy link
Contributor Author

Rebased it, sorry for the delay, hard to find motivation these days :)

@oxinabox
Copy link
Owner

Rebased it, sorry for the delay, hard to find motivation these days :)

Big Mood.
(that is what the young people say, right?)

@oxinabox oxinabox merged commit 5160c38 into oxinabox:main Feb 28, 2021
@gsoleilhac gsoleilhac deleted the gs/edgeToPath branch March 3, 2021 16:26
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.

2 participants