igraph-help
[Top][All Lists]

## Re: [igraph] multiple edges and their attributes

 From: Tamas Nepusz Subject: Re: [igraph] multiple edges and their attributes Date: Wed, 11 Mar 2015 21:55:39 +0100 User-agent: Mutt/1.5.23 (2014-03-12)

```Hi,

The following snippet gives you the edge indices of all the edges in the graph
with multiplicity > 1:

eids = [index for index, is_multiple in enumerate(graph.is_multiple()) if
is_multiple]

If you need the actual edges, then do the following once you have the indices:

graph.es[eids]

--
T.

On 03/11, Jey Narasimhan wrote:
> 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
>
>
> import igraph as ig
> import numpy as np
>
> 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
> https://lists.nongnu.org/mailman/listinfo/igraph-help

--
T.

```