org.codehaus.plexus.util.dag

Class DAG

Implemented Interfaces:
Cloneable, Serializable

public class DAG
extends java.lang.Object
implements Cloneable, Serializable

DAG = Directed Acyclic Graph
Version:
$Id: DAG.java 5958 2007-02-28 10:29:55Z olamy $
Author:
Michal Maczka

Constructor Summary

DAG()

Method Summary

void
addEdge(String from, String to)
void
addEdge(Vertex from, Vertex to)
Vertex
addVertex(String label)
Adds vertex to DAG.
Object
clone()
List
getChildLabels(String label)
Set
getLabels()
List
getParentLabels(String label)
List
getSuccessorLabels(String label)
Return the list of labels of successor in order decided by topological sort
Vertex
getVertex(String label)
List
getVerticies()
boolean
hasEdge(String label1, String label2)
boolean
isConnected(String label)
Indicates if there is at least one edge leading to or from vertex of given label
void
removeEdge(String from, String to)
void
removeEdge(Vertex from, Vertex to)

Constructor Details

DAG

public DAG()

Method Details

addEdge

public void addEdge(String from,
                    String to)
            throws CycleDetectedException

addEdge

public void addEdge(Vertex from,
                    Vertex to)
            throws CycleDetectedException

addVertex

public Vertex addVertex(String label)
Adds vertex to DAG. If vertex of given label alredy exist in DAG no vertex is added
Parameters:
label - The lable of the Vertex
Returns:
New vertex if vertext of given label was not presenst in the DAG or exising vertex if vertex of given labale was alredy added to DAG

clone

public Object clone()
            throws CloneNotSupportedException
See Also:
java.lang.Object.clone()

getChildLabels

public List getChildLabels(String label)
Parameters:
label -
Returns:

getLabels

public Set getLabels()

getParentLabels

public List getParentLabels(String label)
Parameters:
label -
Returns:

getSuccessorLabels

public List getSuccessorLabels(String label)
Return the list of labels of successor in order decided by topological sort
Parameters:
label - The label of the vertex whose predessors are serched
Returns:
The list of labels. Returned list contains also the label passed as parameter to this method. This label should always be the last item in the list.

getVertex

public Vertex getVertex(String label)

getVerticies

public List getVerticies()
Returns:

hasEdge

public boolean hasEdge(String label1,
                       String label2)

isConnected

public boolean isConnected(String label)
Indicates if there is at least one edge leading to or from vertex of given label
Returns:
true if this vertex is connected with other vertex,false otherwise

removeEdge

public void removeEdge(String from,
                       String to)

removeEdge

public void removeEdge(Vertex from,
                       Vertex to)