Comments (9)
Ack, I forgot to mention that you also need to use a directed graph. Below works for me
from pyvis.network import Network
g = Network(directed=True)
g.add_node(0)
g.add_node(1)
g.add_edge(0, 1)
g.add_edge(0, 1)
g.set_edge_smooth('dynamic')
g.show('foo.html')
For an undirected graph, make the arrows really small.
from pyvis.
I'm afraid that doesn't work. I created a simple code:
G = Network(width="800px", height='600px', heading='Test connectivity', layout=True, bgcolor='#aaaaaa')
G.add_node(1, label='1', title='node 1', group=1, level=1)
G.add_node(2, label='2', title='node 2', group=2, level=2)
G.add_edge(1,2, label='link A', title='link A')
G.add_edge(1,2, label='link B', title='link B')
G.set_edge_smooth('dynamic')
G.show('output/tt.html')
Once Iook into generated image, there is only a single edge
from pyvis.
Without nt.set_edge_smooth('dynamic')
they're all drawn on top of each other. See the below example.
from pyvis.network import Network
import networkx as nx
g = nx.MultiGraph()
g.add_node(0)
g.add_node(1)
g.add_edge(0, 1)
g.add_edge(0, 1)
nt = Network(directed=True)
nt.from_nx(g)
nt.set_edge_smooth('dynamic')
nt.show('foo.html')
from pyvis.
So, yes, it seems that this works, but all the links are shown together. For me it works without the nt.set_edge_smooth('dynamic')
...
I'm importing into Network
from networkx
...
nt = Network("500px", "1000px", directed=True)
nt.from_nx(G)
nt.show('g.html')
In [209]: len(nt.edges)
Out[209]: 862
Is there any chance of showing the different links apart from each other, so that they are not superimposed?
from pyvis.
Yes, indeed, you were right ...
I have a different problem now: the nodes keep moving around the webpage, preety much like happy electrons ... :-) ... I believe is because of the several links that I try to show ... I believe I should tweak some of the physics
...
thanks anyway!
from pyvis.
Yeah, here're is the thing. You can disable the the physics as nt.toggle_physics(False)
, but that will put the links back to be drawn in the same way: one over another one.
from pyvis.
This looks to be answered. Closing issue.
Also to @xhdix 's comment going to expand on that a bit. Below is the documentation for each network. MultiGraph
will work with a directed network as it is still a network, but it does not support directions.
MultiDiGraph
MultiGraph
Might be a consideration to add a warning when that option is specified with the incorrect graph type to make it more user friendly.
from pyvis.
You need to enable smooth edges with the "dynamic" algorithm. https://pyvis.readthedocs.io/en/latest/documentation.html#pyvis.network.Network.set_edge_smooth
from pyvis.
For people like me who came to this page from a search: Use MultiDiGraph
instead of MultiGraph
.
Xref: #119
from pyvis.
Related Issues (20)
- Some buttons not working
- Dropdown list button is not precise
- Clustering nodes with same labels?
- Filtering Nodes HOT 1
- Arrows are not displayed on the graph HOT 1
- highlightActive is not defined: Causes wierd jump of graph
- AttributeError: 'NoneType' object has no attribute 'render' HOT 4
- How do you change the fonts of the labels on the nodes?
- Be able to set the color of an edge independently of the source node
- Left to Right Orientation?
- Interactive Node in in Output HOT 1
- Use palette to color nodes and add colorbar
- Edge titles does not work? HOT 6
- Pyvis HTML Output does not use 100% of the page HOT 2
- Save as json
- Problem with labels, trying integration with pandas, Latex and Networkx
- No display of node labels if node is numeric HOT 1
- Change node size when label is inside
- Numeric string node ID silently cast from `str` to `int` in in `add_nodes` but not `add_edges`, raises `AssertionError`
- `write_html` opens browser to relative rather than absolute path, doesn't handle absolute paths as name
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 pyvis.