[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
Gephi forumsPlease post new questions on facebook group too (https://www.facebook.com/groups/gephi) 2014-12-02T21:05:55+01:00 https://forum-gephi.org/app.php/feed/topic/3691 2014-12-02T21:05:55+01:002014-12-02T21:05:55+01:00 https://forum-gephi.org/viewtopic.php?t=3691&p=10922#p10922 <![CDATA[MST via script-plugin via underlyingGraph]]>
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:

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?

Statistics:Posted by rbelew — 02 Dec 2014 21:05


]]>