For using igraph from Python
Home  Trees  Indices  Help 



object +  _igraph.EdgeSeq +  EdgeSeq
Class representing a sequence of edges in the graph.
This class is most easily accessed by the es
field of the
Graph object, which
returns an ordered sequence of all edges in the graph. The edge sequence
can be refined by invoking the EdgeSeq.select() method. EdgeSeq.select()
can also be accessed by simply calling the EdgeSeq object.
An alternative way to create an edge sequence referring to a given graph is to use the constructor directly:
>>> g = Graph.Full(3) >>> es = EdgeSeq(g) >>> restricted_es = EdgeSeq(g, [0, 1])
The individual edges can be accessed by indexing the edge sequence object. It can be used as an iterable as well, or even in a list comprehension:
>>> g=Graph.Full(3) >>> for e in g.es: ... print e.tuple ... (0, 1) (0, 2) (1, 2) >>> [max(e.tuple) for e in g.es] [1, 2, 2]
The edge sequence can also be used as a dictionary where the keys are the attribute names. The values corresponding to the keys are the values of the given attribute of every edge in the graph:
>>> g=Graph.Full(3) >>> for idx, e in enumerate(g.es): ... e["weight"] = idx*(idx+1) ... >>> g.es["weight"] [0, 2, 6] >>> g.es["weight"] = range(3) >>> g.es["weight"] [0, 1, 2]
If you specify a sequence that is shorter than the number of edges in the EdgeSeq, the sequence is reused:
>>> g = Graph.Tree(7, 2) >>> g.es["color"] = ["red", "green"] >>> g.es["color"] ['red', 'green', 'red', 'green', 'red', 'green']
You can even pass a single string or integer, it will be considered as a sequence of length 1:
>>> g.es["color"] = "red" >>> g.es["color"] ['red', 'red', 'red', 'red', 'red', 'red']
Some methods of the edge sequences are simply proxy methods to the corresponding methods in the Graph object. One such example is EdgeSeq.is_multiple():
>>> g=Graph(3, [(0,1), (1,0), (1,2)]) >>> g.es.is_multiple() [False, True, False] >>> g.es.is_multiple() == g.is_multiple() True




Edge 


VertexSeq 


















Inherited from Inherited from 


Inherited from Inherited from 

Returns the first edge of the edge sequence that matches some criteria. The selection criteria are equal to the ones allowed by VertexSeq.select. See VertexSeq.select for more details. For instance, to find the first edge with weight larger than 5 in
graph >>> g.es.find(weight_gt=5) #doctest:+SKIP

Selects a subset of the edge sequence based on some criteria The selection criteria can be specified by the positional and the keyword arguments. Positional arguments are always processed before keyword arguments.
Keyword arguments can be used to filter the edges based on their
attributes and properties. The name of the keyword specifies the name of
the attribute and the filtering operator, they should be concatenated by
an underscore (
For instance, if you want to filter edges with a numeric
>>> g.es.select(weight_gt=50) #doctest: +SKIP Similarly, to filter edges whose >>> list_of_types = ["inhibitory", "excitatory"] >>> g.es.select(type_in=list_of_types) #doctest: +SKIP If the operator is omitted, it defaults to >>> g.es.select(type="intracluster") #doctest: +SKIP In the case of an unknown operator, it is assumed that the recognized
operator is part of the attribute name and the actual operator is
Keyword arguments are treated specially if they start with an
underscore (
For instance, if you want to exclude edges with a betweenness centrality less than 2: >>> g = Graph.Famous("zachary") >>> excl = g.es.select(_edge_betweenness_ge = 2) To select edges originating from vertices 2 and 4: >>> edges = g.es.select(_source_in = [2, 4])
To select edges lying entirely within the subgraph spanned by vertices 2, 3, 4 and 7: >>> edges = g.es.select(_within = [2, 3, 4, 7])
To select edges with one endpoint in the vertex set containing vertices 2, 3, 4 and 7 and the other endpoint in the vertex set containing vertices 8 and 9: >>> edges = g.es.select(_between = ([2, 3, 4, 7], [8, 9]))
For properties that take a long time to be computed (e.g., betweenness
centrality for large graphs), it is advised to calculate the values in
advance and store it in a graph attribute. The same applies when you are
selecting based on the same property more than once in the same
>>> edges = g.es.select(_edge_betweenness_gt=10, # doctest:+SKIP ... _edge_betweenness_lt=30) It is advised to use this instead: >>> g.es["bs"] = g.edge_betweenness() >>> edges = g.es.select(bs_gt=10, bs_lt=30)

Shorthand notation to select() This method simply passes all its arguments to EdgeSeq.select(). 
Proxy method to Graph.count_multiple() This method calls the See Also: Graph.count_multiple() for details. 
Proxy method to Graph.delete_edges() This method calls the See Also: Graph.delete_edges() for details. 
Proxy method to Graph.edge_betweenness() This method calls the See Also: Graph.edge_betweenness() for details. 
Proxy method to Graph.is_loop() This method calls the See Also: Graph.is_loop() for details. 
Proxy method to Graph.is_multiple() This method calls the See Also: Graph.is_multiple() for details. 
Proxy method to Graph.is_mutual() This method calls the See Also: Graph.is_mutual() for details. 
Proxy method to Graph.subgraph_edges() This method calls the See Also: Graph.subgraph_edges() for details. 
Home  Trees  Indices  Help 


Generated by Epydoc 3.0.1 on Fri May 10 10:51:13 2019  http://epydoc.sourceforge.net 