graphi.edge module¶
-
class
graphi.edge.Edge(start, stop, step=None)¶ Bases:
objectAn edge in a graph as a pair of nodes
Parameters: - start – the start or tail of an edge
- stop – the stop or head of an edge
- step – currently unused
This is a verbose interface for creating edges between nodes for use in a graph. It allows using slice notation independent of a graph:
>>> atb = Edge[a:b] >>> a2b = Edge(a, b) >>> graph[a2b] = 1337 >>> graph[a:b] == graph[atb] == graph[a2b] == graph[Edge[a:b]] == graph[Edge(a, b)] True
A
Edgecan also be used for explicit containment tests:>>> Edge[a:b] in graph True
In addition to their slice-like nature,
Edgeis iterable and indexable. This allows for easy unpacking:>>> edge = Edge[a:b] >>> tail, head = edge
Note
This class creates a representation of an edge as a connection between nodes. Edge values can be arbitrary objects.
Warning
Even though
Edgebehaves like aslicein graphs, builtin containers such aslistcannot use aEdge.-
start¶
-
stop¶