Class Graph<T>
- java.lang.Object
-
- hudson.plugins.project_inheritance.util.svg.Graph<T>
-
- Type Parameters:
T
- the type of values in each graph node
public class Graph<T> extends Object
This class implements a very simple directed graph.- Author:
- mhschroe
-
-
Constructor Summary
Constructors Constructor Description Graph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEdges(T node, T... neighbours)
Simple name-wrapper foraddNode(Object, Object...)
, as the code for adding a node or adding edges is identical.void
addNode(T node, T... neighbours)
protected void
addSingleEdge(T start, T end)
protected void
addSingleNode(T node)
Set<T>
getEdgesFor(T node)
Set<T>
getLeaves(Set<T> ignored)
This function returns terminal leaf nodes.Set<T>
getMinimalInboundEdgeNodes(Set<T> ignored)
This function returns all those nodes that have the current minimum number of inbound edges.Set<T>
getMinimalOutboundEdgeNodes(Set<T> ignored)
This function returns all those nodes that have the current minimum of outbound edges.Set<T>
getNodes()
int
getNumNodes()
Graph<T>
getSpanningTree()
void
removeEdge(T start, T end)
void
removeNode(T node)
-
-
-
Method Detail
-
addSingleNode
protected void addSingleNode(T node)
-
addEdges
public void addEdges(T node, T... neighbours)
Simple name-wrapper foraddNode(Object, Object...)
, as the code for adding a node or adding edges is identical.- Parameters:
node
- the nodeneighbours
- its children
-
removeNode
public void removeNode(T node)
-
getNumNodes
public int getNumNodes()
-
getLeaves
public Set<T> getLeaves(Set<T> ignored)
This function returns terminal leaf nodes. That is, it returns all those nodes that do not have any outgoing edges.- Parameters:
ignored
- a set of nodes to ignore for the purpose of identifying leaves. That means those nodes will not be returned, even if they are leaves and nodes that only have edges to them are considered leaves.- Returns:
- a set of leaf nodes.
-
getMinimalOutboundEdgeNodes
public Set<T> getMinimalOutboundEdgeNodes(Set<T> ignored)
This function returns all those nodes that have the current minimum of outbound edges.- Parameters:
ignored
- a set of nodes to ignore for the purpose of counting edges.- Returns:
- a set of nodes with minimal number of outbound edges. Will not
contain any node from
ignored
.
-
getMinimalInboundEdgeNodes
public Set<T> getMinimalInboundEdgeNodes(Set<T> ignored)
This function returns all those nodes that have the current minimum number of inbound edges.- Parameters:
ignored
- a set of nodes to ignore for the purpose of counting edges.- Returns:
- a set of nodes with minimal number of inbound edges. Will not
contain any node from
ignored
.
-
-