Class Search
source code
object --+
|
Search
- Known Subclasses:
-
Forest,
Length,
Postorder,
Predecessor,
Preorder,
Successor
Generic graph traversal (search) class.
Users should generally use the search functions defined below.
e.g. to get a list of all nodes of G in breadth first search (BFS)
order from v use
vertex_list=bfs_preorder(G,v)
To search the graph G from v do the following:
S=Search(G,queue=DFS)
S.search(v=v)
Depending on the type of queue you will get a different traversal type.
You may use any of the following queues from the Queues class:
Name Queue Traversal
----- ------ ----------
DFS LIFO Depth First Search
BFS FIFO Breadth First Search
Random Random Random search
The generic search produces no data and thus is of limited utility.
Visitor callback functions are called at points along the search
which may be used to store shortest path data
|
__init__(self,
G,
queue=<class 'networkx.queues.DFS'>)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
|
|
|
|
start_tree(self,
v)
Visitor function called at the search start
of each connected component. |
source code
|
|
|
firstseen_vertex(self,
v)
Visitor function called the first time a vertex is encountered. |
source code
|
|
|
lastseen_vertex(self,
v)
Visitor function called the last time a vertex is encountered. |
source code
|
|
|
end_tree(self,
v)
Visitor function called at the search end
of each connected component. |
source code
|
|
|
firstseen_edge(self,
e)
Visitor function called the first time an edge is encountered. |
source code
|
|
|
lastseen_edge(self,
e)
Visitor function called the last time an edge is encountered. |
source code
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
Inherited from object :
__class__
|
__init__(self,
G,
queue=<class 'networkx.queues.DFS'>)
(Constructor)
| source code
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- Overrides:
object.__init__
- (inherited documentation)
|
Search the graph.
The search method is deteremined by the initialization of the
search object.
The optional v= argument can be a single vertex a list or None.
v=v: search the component of G reachable from v
v=vlist: search the component of G reachable from v
v=None: search the entire graph G even if it isn't connected
Call visitor functions along the way.
|
Private method to this class.
Search a single connected component starting at the edge e.
To start from a vertex v, use e=(v,v).
Call the visitor functions along the way.
|