-
Notifications
You must be signed in to change notification settings - Fork 40
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
(Un)directed mixed graph #82
Comments
It's not a feature that is currently supported, but I will add it to the TODO list. The only workaround I can see is to plot the network twice, first all edges with arrow heads and then the remaining ones (or vice-versa). import matplotlib.pyplot as plt
import netgraph
edges = [(0, 1), (1, 2), (2, 0)]
# set or precompute node positions
pos = {
0 : (0.1, 0.1),
1 : (0.9, 0.1),
2 : (0.5, 0.7),
}
fig, ax = plt.subplots()
netgraph.Graph(edges[:-1], nodes=[0, 1, 2], node_layout=pos, arrows=True, ax=ax)
netgraph.Graph(edges[-1:], nodes=[0, 1, 2], node_layout=pos, arrows=False, ax=ax)
plt.show() If the desired |
Actually, I came up with a better way that doesn't break interactive Similarly, to issue #83, you can simply instantiate the import matplotlib.pyplot as plt
from netgraph import Graph
fig, ax = plt.subplots()
g = Graph([(0, 1), (1, 2), (2, 0)], arrows=True, node_labels=True, ax=ax)
edge_artist = g.edge_artists[(0, 1)]
edge_artist.head_width = 1e-12 # don't set them to zero as this can cause numerical issues
edge_artist.head_length = 1e-12
edge_artist._update_path()
plt.show() |
Hi, Thank you for the solutions; the second one seems to be the best. I tried to play around with the library and managed to achieve a similar result with minimal modifications. I defined a dictionary called "arrows":
Then, I used the dictionary in the graph definition:
To implement this, I only needed to modify the "draw_edges" method in the "_main.py" script as follows:
instead of
However, I haven't extensively tested this modification for all types of graphs, so I do not know what else it can affects. Luca |
Hi Luca, your proposal is very similar to what I have in mind. Basically, the plan is to support 3 cases:
Would that work for you? |
Yes absolutely :) |
Hi there! Is there the possibility to generate a graph with some edges that are directed (with arrow) and some undirected?
Thank you,
Luca
The text was updated successfully, but these errors were encountered: