MST via script-plugin via underlyingGraph

Extensions and customization
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
rbelew
Posts:4
Joined:09 Sep 2011 22:28
[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
MST via script-plugin via underlyingGraph

Post by rbelew » 02 Dec 2014 21:05

i needed a MST in gephi, and it gave me a chance to play with the Gython/script-plugin facility. the general facility seems a fantastic addition to gephi, thanks very much to all involved in this extension.

but i wound up having to interact with the "underlying" graph because i could not traverse the main graph `g` itself as i'd expected. here's what worked for me:

Code: Select all

subtrees = UnionFind()
Tree = []
nlist = [n for n in g.underlyingGraph.nodes]
sList = []
for u in nlist:
    inbr = [e for e in u.getEdgesInTree()]
    onbr = [e for e in u.getEdgesOutTree()]
    nbrs = inbr + onbr
    for e in nbrs:
        sList.append( (e.weight,u,e.target) )
sList.sort()
for W,u,v in sList:
    if subtrees[u] != subtrees[v]:
        Tree.append((u,v))
        subtrees.union(u,v)
(this is Kruskal's algorithm, depending on a UnionFind operator, like that provided by David Epstein's PADS library https://www.ics.uci.edu/~eppstein/PADS/UnionFind.py )

i was unable to use the `neighbors()` function mentioned in the script-plugin doc https://wiki.gephi.org/index.php/Scripting_Plugin; it generates: "AttributeError: 'org.gephi.graph.dhns.node.AbstractNode' object has no attribute 'neighbors' "

hopes this is of use to others, and i'm curious if others have a cleaner solution?

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
[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