gephi / gephi/gephi-plugins

python-scripting-plugin: get the avg. path length of the graph

Open
#26 0 comments 0 reactions 0 assignees View on GitHub
python-scripting-plugin
Dominant language
No language data
Stars
292
Forks
645
PR merge metrics
No merged PRs in 30d

Description

Dear gephi developers, first of all, thanks for making this python scripting console.
My goal: I am trying to get the characteristic path length of the graph.

This feature required building the toolkit java libraries from the source.
Then, I added the libs.jar to the sys.path.
then, with the following scheme I could access their underlying classes

> > > from org.gephi.project.api import ProjectController

The problem is that, in order to get to my goal (execute the statistic graphDistance)
two inputs are required: 1) GraphModel or HierarchicalGraph 2) attributeModel

1)A valid first input can be obtained through

> > > gu =g.getUnderlyingGraph()
> > > gu is a subclass of HierarchicalGraph, so it's ok
> > > gu.class.**bases**[0].**bases**[0]
> > > < type 'org.gephi.graph.api.HierarchicalGraph'>

2) The second input seems to be more problematic.
it should be of type: org.gephi.data.attributes.api.AttributeModel
How do I get to this?

here is what I tried:

> > > GraphController.getModel() #getGraphModel()
> > > AttributeController.getModel() #getAttributeModel()
> > > AttributeController.getModel().getDirectedGraph()
> > > AttributeController.getModel().getDirectedGraph().getGraph()

All of these complain that no argument is given:
File "", line 1, in
TypeError: getModel(): expected 1-2 args; got 0

Their autocompletion suggest that either giving no arg shoud be ok (but it doesn't work) either arg should be Workspace.
I can't get even get the workspace, for the same reason:

> > > ProjectController.closeCurrentProject()
> > > ProjectController.newProject();
> > > ProjectController.getCurrentWorkspace()
> > > ProjectController.getCurrentProject().

Strange enough, all of these should require no arguments, but my command line replies the same error:
File "", line 1, in
TypeError: getModel(): expected 1-2 args; got 0

Do you guys have a suggestion how to obtain the attributemodel, or even better how to reach directly the average path length?

Labels: python scripting plugin

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.