public class BFS extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
BACKWARD
Backward traversal direction.
|
static int |
BLACK
Color black indicates that the node was processed.
|
protected Map<GraphObject,Integer> |
colors
Color labels.
|
protected Direction |
direction
Whether the direction is FORWARD, it is REVERSE otherwise.
|
protected Map<GraphObject,Integer> |
dist
Distance labels.
|
static boolean |
DOWNWARD
Backward traversal direction.
|
static boolean |
FORWARD
Forward traversal direction.
|
static int |
GRAY
Color gray indicates that the node is in queue waiting to be procecessed.
|
protected int |
limit
Stop distance.
|
protected LinkedList<Node> |
queue
BFS queue.
|
protected Set<Node> |
sourceSet
BFS starts from source nodes.
|
protected Set<Node> |
stopSet
BFS will not further traverse neighbors of any node in the stopSet.
|
static boolean |
UPWARD
Forward traversal direction.
|
static int |
WHITE
Color white indicates the node is not processed.
|
Constructor and Description |
---|
BFS()
Empty constructor for other possible uses.
|
BFS(Set<Node> sourceSet,
Set<Node> stopSet,
Direction direction,
int limit)
Constructor with all parameters.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getColor(Node node)
Gets color tag of the node
|
int |
getLabel(GraphObject go)
Gets the distance label of the object.
|
protected void |
initMaps()
Initializes maps used during query.
|
protected boolean |
isEquivalentInTheSet(Node node,
boolean direction,
Set<Node> set)
Checks if an equivalent of the given node is in the set.
|
protected boolean |
isEquivalentInTheSet(Node node,
Set<Node> set)
Checks if an equivalent of the given node is in the set.
|
protected void |
labelEquivRecursive(Node node,
boolean up,
int dist,
boolean enqueue,
boolean head)
Labels equivalent nodes recursively.
|
protected void |
processNode(Node current)
Processes a node.
|
Map<GraphObject,Integer> |
run()
Executes the algorithm.
|
protected void |
setColor(Node node,
int color)
Sets color tag
|
protected void |
setLabel(GraphObject go,
int label)
Sets the distance label.
|
protected Map<GraphObject,Integer> dist
protected Map<GraphObject,Integer> colors
protected Set<Node> stopSet
protected int limit
protected LinkedList<Node> queue
public static final boolean FORWARD
public static final boolean BACKWARD
public static final boolean UPWARD
public static final boolean DOWNWARD
public static final int WHITE
public static final int GRAY
public static final int BLACK
public BFS(Set<Node> sourceSet, Set<Node> stopSet, Direction direction, int limit)
sourceSet
- Seed of BFSstopSet
- Nodes that won't be traverseddirection
- Direction of the traversallimit
- Distance limitpublic BFS()
public Map<GraphObject,Integer> run()
protected void initMaps()
protected void processNode(Node current)
current
- The current nodeprotected void labelEquivRecursive(Node node, boolean up, int dist, boolean enqueue, boolean head)
node
- Node to label equivalentsup
- Traversing direction. Up means towards parents, if false then towards childrendist
- The labelenqueue
- Whether to enqueue equivalentshead
- Where to enqueue. Head or tail.protected boolean isEquivalentInTheSet(Node node, Set<Node> set)
node
- Node to check equivalentsset
- Node setprotected boolean isEquivalentInTheSet(Node node, boolean direction, Set<Node> set)
node
- Node to check equivalentsdirection
- Direction to go to get equivalentsset
- Node setprotected int getColor(Node node)
node
- Node to get color tagprotected void setColor(Node node, int color)
node
- node to set color tagcolor
- the color tagpublic int getLabel(GraphObject go)
go
- object to get the distanceprotected void setLabel(GraphObject go, int label)
go
- object to set the distance labellabel
- the distance labelCopyright © 2015 BioPAX. All rights reserved.