Skip to content

Instantly share code, notes, and snippets.

@ypanagis
Last active October 20, 2022 14:40
Show Gist options
  • Save ypanagis/ad2f3d6dd3cc5e453e666ee9c5385b72 to your computer and use it in GitHub Desktop.
Save ypanagis/ad2f3d6dd3cc5e453e666ee9c5385b72 to your computer and use it in GitHub Desktop.
Gephi gist to delete all nodes with specific attribute (Modularity class)
# Delete some nodes from Gephi graph
# run from Gephi scripting console as execfile("/Fullpath/gephi_del.py") or
# execfile("C:\\Fullpath\\gephi_del.py") for windows
# Delete all nodes from Modularity class 5
subgraph = g.filter(modularity_class == 5) # first filter those out to a new subgraph
# Then iterate and delete
for v in subgraph.nodes:
print v.label # just testing which node is accessed
del v
# Now it should work!
@arpicheck
Copy link

This will not work, as soon you put the functionality inside of a method.
Please include a solution, where 'del' actually is located inside of a method an works well.

@ypanagis
Copy link
Author

You are right it is strange with the method, even though I could print v.label, del v has no real effect. I can speculate that ir works on a copy of the nodes...

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