In the networkx library is possible to click on a node and hi-light it and it’s edges.
This page illustrates this solution:
Interactive networkx. This is a desktop-based solution.
I tried to find a similar solution for the igraph library but I can't find it.
Currently, I use d3 and sigma.js for this purpose. But I'm interested in a desktop-based solution, similar to the above mentioned for the networkx library.
Does anyone know any desktop-based solution for interactively highlight nodes and edges using igraph library?
Thank you in advance.
Related
I'm wondering if it is possible to plot a vertex as image (loaded from a file or directly) in Igraph. Any ideas?
This is definitley possible in the R version of iGraph using the raster function, however a brief search did not reveal any implementation of this function in Python (it's not in the igraph documentation anyway).
If this is essential to your work, then I would consider switching to R, or possibly another tool such as Gephi. For Python, however, you might consider using something like pyvis. This package is small but powerful in terms of visualization. I've been playing around with it over the past few days and its very easy to display a graph with pictures as nodes, and it comes with the added benefit of providing interactive functioning. Take a look at the tutorial here, which will highlight what this package can provide.
Suppose I have to create a graph with 15 nodes and certain nodes. Instead of feeding the nodes via coding, can the draw the nodes and links using mouse on a figure? Is there any way to do this interactively?
No.
Sorry. In principle it could be possible to create a GUI which interfaces with networkx (and maybe some people have), but it's not built directly into networkx.
I'm trying to use Python to plot simple hierarchical tree. I'm using the networkx module. I declared a simple graph
G=networkx.DiGraph()
After adding nodes and edges into G, I tried using
nx.draw(G)
or
nx.draw_networkx(G)
to plot. The output plot hierarchy are all correct, but the position of the nodes appears all random on the graph. Even worse, each time I ran the script, the node position are different.
There is a solution provided in a similar question which requires graphviz package.
pos=nx.graphviz_layout(G,prog='dot')
nx.draw(G,pos,with_labels=False,arrows=False)
Unfortunately I'm not allowed to install graphviz. So I'm seeking alternative solution here.
From graphviz solution, it looks like it's only needed to compute position of the node. Is it correct to say that, as long as I specify a list of coordinates to the draw command, I would be able to plot node at the correct location?
Thanks
UPDATE (15 Apr 2015) Look at my answer here for code that I think will do what you're after.
So networkx doesn't make it particularly easy to use the graphviz layout if you don't have graphviz because it's a better idea to use graphviz's algorithm if you're trying to reproduce graphviz's layout.
But, if you're willing to put in the effort to calculate the position for each node this is straightforward (as you guessed). Create a dict saying where each node's position should be.
pos = {}
for node in G.nodes():
pos[node] = (xcoord,ycoord)
nx.draw(G,pos)
will do it where xcoord and ycoord are the coordinates you want to have.
The various plotting commands are described here
I try to draw multigraph in Python using graphviz.
For now I can draw usual graphs in Python somehow like:
import pygraphviz as pgv
G=pgv.AGraph()
G.add_node('a')
G.add_node('b')
G.layout()
G.add_edge('a','b','first')
G.add_edge('a','b','second')
sorted(G.edges(keys=True))
G.draw('file.png')
And I get on the output:
But actually I want get multigraph, i.e.
But documentation stays that it should differentiate :
I have no idea about drawing multigraph but not just graph.
Thanks for any help.
Addition:
it seems that there are no yet such libraries in python that can do it, so I did it using Wolfram Mathematica. But question is still opened.
Addition
Now working code looks so:
import pygraphviz as pgv
G=pgv.AGraph(strict=False)
G.add_node('a')
G.add_node('b')
G.layout()
G.add_edge('a','b','first')
G.add_edge('a','b','second')
sorted(G.edges(keys=True))
G.draw('file.png')
As the documentation you quoted says, you need to specify strict=False when creating a multi-edge graph. Since you didn't do this your graph doesn't support parallel edges.
I am using networkx package to draw power law graphs. I want to simulate a search algorithm on this graph and want to visually see the algorithm move from one node to another on the graph. How do I do that?
On a mac you could use NodeBox: http://nodebox.net/.
NetworkX supports drawing using Graphviz and matplotlib. Did you read the drawing-chapter in its documentation?