Comments (14)
It seems that the issue is specific to EditableMultiGraph (Maybe EditableGraph too).
from netgraph import EditableMultiGraph
g = EditableMultiGraph([(0, 1, 0)], node_labels={0 : "lorem ipsum", 1 : "dolor sit"}, node_label_offset=0.1, node_label_fontdict=dict(size=40))
plt.show()
Try Editable and non-editable and see the difference. I am not sure if the issue is exactly what I have indicated, but the font size is small and I could not find a way to make it bigger.
And I do need editable, cause there is a lot of label overlap in initial initial positioning of complex graphs. Can't see much from it..
from netgraph.
Most (if not all) sorts are only there to make badly written tests reproducible. So, no, probably not, but I am slightly reluctant to remove the sorting while my brain is still this sluggish.
from netgraph.
So solution to solve this could be:
def _simplify_multigraph(edges):
return list({(source, target) for source, target, _ in edges})
There used to be a sorted
call there that returned a list instead of a set. ;-)
But thanks for the heads up; should be fixed now.
The hard-coded directed=False
is correct though. The Fruchterman-Reingold algorithm (as pretty much all node layout algorithms) was developed for undirected graphs. If you use the directed graph instead, the algorithm typically requires a lot more iterations to settle on solution, which is typically worse (longer average edge lengths, more edge crossings).
from netgraph.
I have a bad cold at the moment, so my brain is at 20% efficiency right now but I will look into these issues once I am better, hopefully later this week.
node_label are being "fitted" into node, even if node_label_offset is not == (0, 0). Long names are just impossible to see given text is being rescaled with no possibility to zoom in.
Shouldn't happen and I will fix that but in the meantime, setting the font size explicitly with node_label_fontdict=dict(size=12)
(or similar) should fix the font size to -- in this case -- 12 pts.
There are couple of places, where nodes and edges are being sorted. This raises an error if nodes and labels are not of the same type. I used key argument for sorted to solve the issue at first, then I duplicated my graph before plotting converting nodes to same type.
Can you post the error trace? Don't really see where or why that would happen.
from netgraph.
These two were the issues in my case:
netgraph/_utils.py: 932
netgraph/_edge_layout.py: 1314
But check the others too:
# grep sorted
./_node_layout.py: nodes = sorted(_get_unique_nodes(edges))
./_node_layout.py: nodes = sorted(_get_unique_nodes(edges))
./_node_layout.py: return left, sorted(right_ranks, key=right_ranks.get)
./_utils.py: components = sorted(components, key=len, reverse=True)
./_utils.py: # return sorted(_map_multigraph_source_target_pairs_to_edge_ids(edges))
Hope you get well soon.
from netgraph.
I can't reproduce the second issue. Node labels are not rescaled for non-zero node label offsets.
from netgraph import Graph
Graph([(0, 1)], node_labels={0 : "lorem ipsum", 1 : "dolor sit"}, node_label_offset=0.1)
plt.show()
Can you provide a MWE that produces the issue on your end?
from netgraph.
What about 3? Is that sorting needed?
from netgraph.
Mixed node types are now supported in Netgraph. I either removed calls to sorted
or wrapped them in a try/except block.
from netgraph.
I will close the issue for now as I think I have addressed all sub-issues but feel free to re-open if that turns out not to be the case.
from netgraph.
Thank you! One more error:
_utils.py:120
File "/usr/local/lib/python3.11/site-packages/netgraph/_utils.py", line 120, in _edge_list_to_adjacency_list
edges = edges + [(target, source) for (source, target) in edges] # forces copy
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'set' and 'list'
if I wrap edges in list:
if not directed:
edges = list(edges) + [(target, source) for (source, target) in edges] # forces copy
All works fine, but I wander if it was ever meant to be set in the first place?
it gets converted to a set in
_utils.py:934:
def _simplify_multigraph(edges):
return {(source, target) for source, target, _ in edges}
The other concern is that I am running MultiDiGraph, so that if not directed
should not be evaluated to True in the first place.
from netgraph.
So solution to solve this could be:
def _simplify_multigraph(edges):
return list({(source, target) for source, target, _ in edges})
But also, have a look at that argument, which is hardcoded at:
netgraph/_node_layout.py:53
adjacency_list = _edge_list_to_adjacency_list(edges, directed=False)
although it is being used for directed graphs...
from netgraph.
All works now. Thank you.
from netgraph.
And: one does get notifications on closed issues.
from netgraph.
Ok, thank you. Good to know.
from netgraph.
Related Issues (20)
- Problems with very large graphs HOT 12
- Installation not working with python 3.11 HOT 5
- Minor documentation issues HOT 3
- ArcDiagram throws warning, does not label nodes, does not preserve node order. HOT 2
- Way to specify linestyle for edges? HOT 2
- Unable to use Community layout for Multi-Component graph? HOT 4
- Not specifying node_edge_width when node_size is small causes node colours to not show up HOT 2
- How can I change the direction of a dot graph? HOT 1
- Strange Axis BoundingBox "diamond" HOT 3
- Combining interactive graphs with networkx subgraph functions? HOT 6
- (Suggestion) Handling div-by-zero HOT 1
- (Un)directed mixed graph HOT 5
- Changing arrow size while keeping edge width intact HOT 3
- self-loop labeling problem using EditableGraph HOT 2
- Embedding NetGraph EditableGraph in PyQt5 HOT 3
- Bundle_parallel_edges problem HOT 4
- Fixed node size in Netgraph ? HOT 18
- Add multiple edges simultaneously HOT 11
- Overlapping nodes Fix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netgraph.