PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, June 28, 2022

[FIXED] How to draw oriented edges on PyVis

 June 28, 2022     data-visualization, graph, networkx, python, pyvis     No comments   

Issue

I'm trying to plot an oriented graph with pyvis. In the documentation they suggest using the following command for creating an oriented edge:

net.add_edge(4,1,from=1,to=4)

The problems are two:

  1. I'm getting this error

TypeError: add_edge() got multiple values for argument 'to'

  1. from is a python keyword so it can't be used as a parameter.

Any suggestion?


Solution

You don't need to directly specify to and from in your add_edge function if you had specified directed=True when you created your network. The order of the nodes in the add_edge function is enough to describe the direction. Below is an example:

from pyvis.network import Network

net = Network(directed =True)
net.add_node(0, label='a')
net.add_node(1, label='b')
net.add_edge(0,1)
net.show('mygraph.html')

And the output gives:

enter image description here



Answered By - jylls
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing