public class DependencyGraph extends Object
Constructor and Description |
---|
DependencyGraph(int numStreams,
boolean allowDependencySame)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(int target,
int from)
Adds a single dependency of target on a required streams.
|
void |
addDependency(int target,
SortedSet<Integer> requiredStreams)
Adds dependencies that a target may have on required streams.
|
Map<Integer,SortedSet<Integer>> |
getDependencies()
Returns a map of stream number and the streams dependencies.
|
Set<Integer> |
getDependenciesForStream(int stream)
Returns the set of dependent streams for a given stream.
|
Stack<Integer> |
getFirstCircularDependency()
Returns any circular dependency as a stack of stream numbers, or null if none exist.
|
int |
getNumStreams()
Returns the number of streams.
|
Set<Integer> |
getRootNodes()
Returns a set of stream numbers that are the root dependencies, i.e.
|
Set<Integer> |
getRootNodes(Set<Integer> ignoreList)
Return the root nodes ignoring the nodes provided.
|
boolean |
hasDependency(int stream)
Returns true if the stream asked for has a dependency.
|
boolean |
hasUnsatisfiedDependency(int navigableStream,
Set<Integer> ignoreList)
Check if the given stream has any dependencies, direct or indirect, to any of the streams that are not in the ignore list.
|
String |
toString() |
public DependencyGraph(int numStreams, boolean allowDependencySame)
numStreams
- - number of streamsallowDependencySame
- - allow same-dependency streampublic int getNumStreams()
public void addDependency(int target, SortedSet<Integer> requiredStreams)
target
- the stream having dependencies on one or more other streamsrequiredStreams
- the streams that the target stream has a dependency onpublic void addDependency(int target, int from)
target
- the stream having dependencies on one or more other streamsfrom
- a single required streams that the target stream has a dependency onpublic boolean hasDependency(int stream)
stream
- to check dependency forpublic Set<Integer> getDependenciesForStream(int stream)
stream
- to return dependent streams forpublic Map<Integer,SortedSet<Integer>> getDependencies()
public Set<Integer> getRootNodes()
public Set<Integer> getRootNodes(Set<Integer> ignoreList)
ignoreList
- nodes to be ignoredpublic Stack<Integer> getFirstCircularDependency()
public boolean hasUnsatisfiedDependency(int navigableStream, Set<Integer> ignoreList)
ignoreList
- ignore listnavigableStream
- to-stream