class documentation

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
Method __call__ Shorthand notation to select()
Method attributes Returns the list of all the edge attributes in the graph associated to this edge sequence.
Method find Returns the first edge of the edge sequence that matches some criteria.
Method select Selects a subset of the edge sequence based on some criteria

Inherited from EdgeSeq:

Method attribute_names Returns the attribute name list of the graph's edges
Method get_attribute_values Returns the value of a given edge attribute for all edges.
Method is_all Returns whether the edge sequence contains all the edges exactly once, in the order of their edge IDs.
Method set_attribute_values Sets the value of a given edge attribute for all vertices
Attribute graph The graph the edge sequence belongs to
Attribute indices The edge indices in this edge sequence
def __call__(self, *args, **kwds): (source)

Shorthand notation to select()

This method simply passes all its arguments to EdgeSeq.select().

def attributes(self): (source)

Returns the list of all the edge attributes in the graph associated to this edge sequence.

def find(self, *args, **kwds): (source)
overrides