Re-layout from script

Algorithms and parameters to put data in space
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Gsettanni
Posts:2
Joined:08 Feb 2012 18:06
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Re-layout from script

Post by Gsettanni » 24 Feb 2012 11:39

Hi there,
I would like to access to my gephi graph through a jython script, and periodically re-layout the graph.
I tried using the script console plugin, and it works fine! But I have to launch the script from the GUI every time I want to re-layout the graph, it is not possible to update the graph layout automatically as soon as the graph changes (nodes or edges are added/deleted) :-(

Moreover, I would like to integrate these re-layouting commands in another python script that I'm already using to update the nodes and the edges of the graph (I'm using the streaming plugin to achieve that).

Is it possible to include, in the python script I'm using for create and update the graph via stream, the commands that I would need to manage the graph layout, so that I can see (in real time) the graph updating and re-layouting automatically?

If it's possible, does anybody have ideas about how to do that?

Thanks in advance.
Cheers,
Giuseppe.

User avatar
eduramiba
Gephi Code Manager
Posts:1064
Joined:22 Mar 2010 15:30
Location:Madrid, Spain
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Re-layout from script

Post by eduramiba » 25 Feb 2012 17:02

Hi Giuseppe,
What layout are you using?
Most layouts never stop so they will re-layout when the graph changes.

But if it is a layout that stops and you want to automatically do the layout when the graph changes you could register a graph listener.
In the scripting plugin that would be done with some code like the following:

Code: Select all

import org.gephi.graph.api as graph_api
graphModel = gephi.getLookup().lookup(graph_api.GraphController).getModel()

class MyListener(graph_api.GraphListener):
    def graphChanged(self,event):
        #Do layout here...
		
listener = MyListener()
graphModel.addGraphListener(listener)
But I tried and it does not work, events don't reach the listener. Does anyone have an idea? I may be making some mistake.

Eduardo

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable