Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting mixed graphs #134

Open
bvilmann opened this issue Dec 9, 2020 · 2 comments
Open

Plotting mixed graphs #134

bvilmann opened this issue Dec 9, 2020 · 2 comments

Comments

@bvilmann
Copy link

bvilmann commented Dec 9, 2020

Hi!

I am fairly new to Julia but I am amazed and I started using GraphPlot. I have an idea for improvement and I would also really like to contribute with this via a PR.

However, since I am quite new to github also, I want to discuss my idea with you before going into action (and start learning how to use github properly regarding PRs meanwhile).

Mixed graphs:
It could be nice if GraphPlot could do mixed graphs too.

I think a simple and fine implementation could be via an individual mapping of the edges. In a lot of plotting cases, you have already done your mapping.

The origin of this issue, e.g., was that I wanted to plot the optimization of a transport model. I had all the flows in the graph mapped to an edge color corresponding to a flow/capacity-ratio:
transport_model1

Here, it could just be nice to write something like:
gplot(g,arrowlengthfrac=[abs(flow[i]) > 0 ? 0.1 : 0 for i in 1:num_of_edges])

And thereby avoiding the arrows of all the grey edges, which just disturbs the image.

I have looked into plot.jl and lines.jl, and it seems doable without too much effort and without mess up the control flow of the code.

Perspectives:
I have the impression that GraphPlot is built around LightGraphs and MixedGraph() is not yet a method. But preparing for a graph tool, in the case of a future MixedGraph() method, could be nice either way.

What do you think?
Do you find any immediate issues or should I try to start making it work?

All the best,
Benjamin

@hdavid16
Copy link
Contributor

Great idea. We basically need to support arrowlengthfrac to be a vector of reals, rather than a Real. Would you still be interested in taking a stab at it?

@hdavid16
Copy link
Contributor

hdavid16 commented Apr 3, 2023

@bvilmann you can accomplish this with GraphMakie.jl by setting the arrow size to 0 for those edges where you don't want an arrow:

using Graphs, GraphMakie, GLMakie

g = cycle_graph(4)
graphplot(g, arrow_size=[20,0,20,0], arrow_shift=:end)

image

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

No branches or pull requests

2 participants