Home | Trees | Indices | Help |
|
---|
|
object --+ | core.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]
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
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
VertexSeq |
|
||
Inherited from Inherited from |
|
|||
Inherited from Inherited from |
|
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.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. |
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. 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)
Similarly, to filter edges whose >>> list_of_types = ["inhibitory", "excitatory"] >>> g.es.select(type_in=list_of_types) If the operator is omitted, it defaults to >>> g.es.select(type="intracluster") 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
Attribute names inferred from keyword arguments are treated specially
if they start with an underscore (
>>> excl = g.es.select(_edge_betweenness_ge = 2)
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
>>> g.es.select(_edge_betweenness_gt=10, _edge_betweenness_lt=30)
It is advised to use this instead: >>> g.es["bs"] = g.edge_betwenness() >>> g.es.select(bs_gt=10, bs_lt=30)
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Aug 16 21:30:46 2008 | http://epydoc.sourceforge.net |