Hi,

I am looking for an efficient way to extract all the multiple edges
and working on them before deleting them from the graph.

I have come up with the following way to extract them, but since I am
a beginner of igraph, I am not sure about the efficiency, or if some
operations could be done in less steps, perhaps using simplify
function. Please comment.


import igraph as ig
import numpy as np

myg1 = ig.Graph.Read_GraphML(sys.argv[1])
multval = myg1.is_multiple()
locsuniqval = np.where(np.asarray(multval)==False)[0]
uniqedges_cm = myg1.count_multiple(locsuniqval)
uniq_cm = np.where(np.asarray(uniqedges_cm)>1)[0]
nonmultedges = ig.EdgeSeq(myg1, locsuniqval[uniq_cm])
for nm in nonmultedges:
    tempdict={}
    for name in nm.attribute_names():
        tempdict[name]=[]
    for e in myg1.es.select(_within=[nm.source, nm.target]):
        if e.tuple == nm.tuple:
            for name, val in e.attributes().iteritems():
                tempdict[name].append(val)
        else:
            print 'something wrong'
    print tempdict

_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to