public class BFSDistanceLabeler<V,E>
extends java.lang.Object
Running time is: O(m)
Constructor and Description |
---|
BFSDistanceLabeler()
Creates a new BFS labeler for the specified graph and root set
The distances are stored in the corresponding Vertex objects and are of type MutableInteger
|
Modifier and Type | Method and Description |
---|---|
int |
getDistance(Hypergraph<V,E> g,
V v)
Given a vertex, returns the shortest distance from any node in the root set to v
|
java.util.Map<V,java.lang.Number> |
getDistanceDecorator()
Returns a map from vertices to minimum distances from the original source(s).
|
java.util.Set<V> |
getPredecessors(V v)
Returns set of predecessors of the given vertex
|
java.util.Set<V> |
getUnvisitedVertices()
Returns the set of all vertices that were not visited
|
java.util.List<V> |
getVerticesInOrderVisited()
Returns the list of vertices visited in order of traversal
|
protected void |
initialize(Hypergraph<V,E> g,
java.util.Set<V> rootSet) |
void |
labelDistances(Hypergraph<V,E> graph,
java.util.Set<V> rootSet)
Computes the distances of all the node from the starting root nodes.
|
void |
labelDistances(Hypergraph<V,E> graph,
V root)
Computes the distances of all the node from the specified root node.
|
public BFSDistanceLabeler()
public java.util.List<V> getVerticesInOrderVisited()
public java.util.Set<V> getUnvisitedVertices()
public int getDistance(Hypergraph<V,E> g, V v)
v
- the vertex whose distance is to be retrievedpublic java.util.Set<V> getPredecessors(V v)
v
- the vertex whose predecessors are to be retrievedprotected void initialize(Hypergraph<V,E> g, java.util.Set<V> rootSet)
public void labelDistances(Hypergraph<V,E> graph, java.util.Set<V> rootSet)
graph
- the graph to labelrootSet
- the set of starting vertices to traverse frompublic void labelDistances(Hypergraph<V,E> graph, V root)
graph
- the graph to labelroot
- the single starting vertex to traverse frompublic java.util.Map<V,java.lang.Number> getDistanceDecorator()
labelDistances
in order to contain valid data.Copyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence