Removing a internal PropertyMap from a Graph in graph-tool - python

For the purpose to save a graph without a specific PropertyMap (added with g.vp.foo = vprop) we need to remove it from a Graph g.
The PropertyMap is already present after the loading of the Graph from file.
How can I either remove a PropertyMap from the loaded Graph? (Or alternatively is there a way to copy only the Graph into a new one, without the PropertyMaps?)

Duhhh, found the answer just some lines below from where I copied the example above:
del g.vertex_properties["foo"]

Related

PyVis - search Node

I am using PyVis to build a graph (essentially a call chain). So I like how it generates a html file, with related code, to visualize it.
Is there a way I can generate a 'Search node" functionality ? The Graph I am loading is huge, and a function to zoom in to a node of interest, is what I am looking for...
There is a filter function in PyVis.
When creating the network instance, set filer_menu parameter to True.
And there is search menu shown in html file.
g = Network('1200px', width="100%", notebook=True, directed=True, filter_menu=True)
reference from https://pyvis.readthedocs.io/en/latest/tutorial.html#edges

Convert networkx graph to dot format in python

I am converting my networkx graph using the following code.
nx.drawing.nx_pydot.write_dot(G,path)
It creates a correct dot format which I can visualize later using graphviz interface. However, instead of adding multiple existing lines(Arcs, edges whatever you say), it creates a single (or two if there is an edge in the opposite direction). I just want to have all lines to be preserved in the dot format. How can I do that?
The creation of Networkx graph in the first place was not correct. I changed the line G=nx.DiGraph(directed=True) to G=nx.MultiDiGraph(directed=True). Now I do not have that problem.

delete/modify an edge in graphviz

is there any way to delete an existing edge in a graph?
For example, when I draw an edge using
self.g.edge('a', 'b')
where self.g is my digraph, then I do
self.g.edge('a', 'b', _attributes={'arrowhead': 'dot'})
it draws another edge from a->b so now there are 2 edges instead of 1
basically what I'm trying to do is modify the existing edge
it works for nodes, but not edges
I don't think you can delete or modify anything with this library, but you can avoid multiple edges by initializing the graph with Digraph(strict=True) or similar.
The reason it seems to work for nodes is that Graphviz itself replaces an existing node if a new one with the same name is added later.

Generating Network graph in python

I am trying to generate a network graph for 200+ nodes and 300+ edges using networkx using python from a file. I was able to generate and plot the graph using matplotlib in my Juypter Notebook, but its not looking good and nodes are so tightly packed.
Is there any other python package help to generate network graph ??.
My aim is to generate graph for whole data set so that I can find dependency between nodes.
If nodes being too close together is the issue, try using the draw_spring()function of networkx.
https://networkx.github.io/documentation/networkx-2.0/reference/generated/networkx.drawing.nx_pylab.draw_spring.html#networkx.drawing.nx_pylab.draw_spring
It simulates what would happen if each edge were a spring and the network were picked up and spun around, seperating the nodes, especially the ones which are not connected via many paths.
If this does not work initially, you can use the parameters of the function that draw_spring() wraps, the spring_layout() function. Try adjusting the k value parameter. This should allow you to manipulate the rough distance between nodes.
https://networkx.github.io/documentation/networkx-2.0/reference/generated/networkx.drawing.layout.spring_layout.html#networkx.drawing.layout.spring_layout
Alternatively, there are additional draw functions you might find more useful than draw_spring(). You can find them in the draw section here: https://networkx.github.io/documentation/networkx-2.0/reference/drawing.html
I can recommend using Netwulf. Input a networkx.Graph object to netwulf.visualize, and launch the visualization in a new browser window. The result and data can be posted back to Python.
Disclaimer: I co-author Netwulf.

How to render DOT file using only pos attributes

I have taken an initial DOT file and modified the pos attributes of some nodes using pydot. Now I want to render an image file that shows the nodes in their new positions. The catch is, I don't want a layout program to mess with the positions! I just want to see the nodes exactly where the pos attribute indicates. I don't care about how the edges look.
I can produce a DOT file with my positions easily using pydot, but I can't figure out how to make an image file, either in pydot or on the command line with dot. Help would be really appreciated! Thanks!
dot.write_png('filename.png')? Or is there something I'm missing?
Also, the neato command-line program has a -n option for graph files that already have layout. The program description says it is for undirected graphs, but I tried it with a digraph and it produced the correct result.

Categories

Resources