Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete node does not work if used from a method #278

Open
arpicheck opened this issue Oct 2, 2022 · 3 comments
Open

Delete node does not work if used from a method #278

arpicheck opened this issue Oct 2, 2022 · 3 comments

Comments

@arpicheck
Copy link

Which Plugin?

python-scripting-plugin

Expected Behavior

del statement work from methods as well

Current Behavior

Using del statement works well when issued from the console, but does not have any effect, when used inside of a method.

Possible Solution

Steps to Reproduce

def removeNodes()
for node in g.nodes:
del node

removeNodes()

The above statement should result in all nodes removed from the graph. Instead, it has no effect.
As far as I know, the plugin does not give any other solution for removing nodes.

I tried
g.nodes.remove(...)

but couldn't figure out if this would work with any key.

Context

I can't use python scripts solving complex solutions. One has to always copy/paste scripts into console.

Your Environment

  • Gephi Version used: Gephi 0.9.7 202208031831
  • Plugin Version used: 0.9.2
  • Operating System: Windows 8.1
@ypanagis
Copy link

ypanagis commented Oct 15, 2022

You can actually both delete noes and run a Python script from the python script plugin. I have created a gist that should work for you.

The gist filters nodes that have a specific modularity class, adds them to a subgraph and deletes them. You can run it from the scripting plugin by giving
>>> execfile("/path_to_script/script.py") .

See some more functionality of the scripting pluging at the official plugin documentation.

@ypanagis
Copy link

The above does not actually work if the del v part, for node v, is inside a function. Perhaps delete inside a function, operates on node copies, but this is just a speculation so far

@arpicheck
Copy link
Author

Other reasoning could be that 'del' is overridden somehow and has no effect at al, or does something else we don't recognize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants