How to create Gephi network graphics from Python?

I just found out about GephiStreamer. https://pypi.python.org/pypi/GephiStreamer

Using this package, you can send instructions from python to Gephi to create nodes and edges in Gephi.

# Create a node with a custom_property node_a = graph.Node("A",custom_property=1) # Create edge edge_ab = graph.Edge(node_a,node_b,custom_property="hello") stream.add_edge(edge_ab) 

In the same way, I want to do everything in Gephi through Python. This is what I usually do.

Example:

actions:

  • load nodes

  • loading edges

  • calculate central centrality

  • resize / color nodes according to their centrality estimates

  • change the graph layout (e.g. forceatlas2)

  • specify output schedule

Below is the result that I have manually, but I want to create it by sending instructions from python to Gephi. The documentation says nothing about creating nodes, edges, and graphs.

I also found out about NetworKit. https://networkit.iti.kit.edu/data/uploads/docs/NetworKit-Doc/python/html/gephi.html

This is slightly better than gephistramer, but it requires python 3.4 or higher, and most packages like pandas, numpy or sickit are in 2.7.

There is also a way to send the file that I created in gephi back to python.

Please offer.

PS: I edited all the details of the question so that now it is easier to understand (I hope).

+6
source share
2 answers

I found this question, looking for the answer itself. I chose Gephi as my visualizer and then wanted to build a graph that was well maintained by the tool, pulling data from my organization using Python.

I found GephiStreamer and it looks like a simple but comprehensive way to plot graphs in Gephi from an external python environment (command line or IDE),

Other options at this stage:

+5
source

There is no simple answer to this. People from the Facebook group may know something, but IMO is the best way to do this is to call the Gephi toolkit , i.e. An accessible jar, from jython, check here for an example use. The fact is that jython does not allow you to install numpy and a number of other libraries, but I think you could work around this problem by connecting the output of one script to another or using a queue such as Celery.

So, I would write a script to name it graph_construction.py , which uses networkx, build a graph and then write it to standard output in gexf. Then I will write a second script, gephi.py , which will execute things in gephi and let it say a graph in pdf, and then do something like:

 python graph_construction.py | jython gephi.py output.pdf 

and pray that it works.

+2
source

All Articles