Class GraphNode
- java.lang.Object
-
- edu.isi.pegasus.planner.classes.Data
-
- edu.isi.pegasus.planner.partitioner.graph.GraphNode
-
- All Implemented Interfaces:
java.lang.Cloneable
public class GraphNode extends Data
Data class that allows us to construct information about the nodes in the abstract graph. Contains for each node the references to it's parents and children. The direction of the edges is usually following the children from a node. Parents are kept to facilitate bottom up traversals.- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description static int
BLACK_COLOR
static int
GRAY_COLOR
private Bag
mBag
A Bag of objects that maybe associated with the node.private java.util.Set<GraphNode>
mChildren
The list of children of the job/node in the abstract graph.private int
mColor
The color the node is colored.private GraphNodeContent
mContent
The content associated with this node.private int
mDepth
The depth of the node from the root or any arbitary node.private java.lang.String
mLogicalID
The logical id of the job as identified in the dax.private java.lang.String
mLogicalName
The logical name of the node as identified in the dax.private java.util.Set<GraphNode>
mParents
The list of parents of the job/node in the abstract graph.static int
WHITE_COLOR
-
Constructor Summary
Constructors Constructor Description GraphNode()
The default constructor.GraphNode(java.lang.String id)
The overloaded constructor.GraphNode(java.lang.String id, GraphNodeContent content)
The overloaded constructor.GraphNode(java.lang.String id, java.lang.String name)
The overloaded constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(GraphNode child)
Adds a child to end of the child list.void
addParent(GraphNode parent)
Adds a parent to end of the parent list.boolean
childrenColored(int color)
Returns if all the children of the node have the color that is specified.java.lang.String
childrenToString()
A convenience methods that generates a comma separated list of children as Stringjava.lang.Object
clone()
Returns a copy of the object.boolean
equals(java.lang.Object obj)
Matches two GraphNode objects.Bag
getBag()
Returns the bag of objects associated with the node.java.util.Collection<GraphNode>
getChildren()
Returns a list ofGraphNode
objects that are children of the node.GraphNodeContent
getContent()
Returns the content associated with the node.int
getDepth()
Returns the depth of the node in the graph.java.lang.String
getID()
Returns the logical id of the graph node.java.lang.String
getName()
Returns the logical name of the graph node.java.util.Collection<GraphNode>
getParents()
Returns a list ofGraphNode
objects that are parents of the node.int
hashCode()
Calculate a hash code value for the object to support hash based Collections.boolean
isColor(int color)
Returns if the color of the node is as specified.boolean
parentsColored(int color)
Returns if all the parents of that node have the color that is specified.java.lang.String
parentsToString()
A convenience methods that generates a comma separated list of parents as Stringvoid
removeChild(GraphNode child)
Removes a child linkage to the node.void
removeParent(GraphNode parent)
Removes a parent linkage to the node.void
resetEdges()
Reset all the edges associated with this node.void
setBag(Bag bag)
Sets the bag of objects associated with the node.void
setChildren(java.util.Collection<GraphNode> children)
It sets the children to the node.void
setColor(int color)
Sets the color of the node to the color specifiedvoid
setContent(GraphNodeContent content)
Sets the content associated with the node.void
setDepth(int depth)
Sets the depth associated with the node.void
setParents(java.util.Collection<GraphNode> parents)
It adds the parents to the node.java.lang.String
toString()
The textual representation of the graph node.-
Methods inherited from class edu.isi.pegasus.planner.classes.Data
setToString, vectorToString
-
-
-
-
Field Detail
-
WHITE_COLOR
public static final int WHITE_COLOR
- See Also:
- Constant Field Values
-
GRAY_COLOR
public static final int GRAY_COLOR
- See Also:
- Constant Field Values
-
BLACK_COLOR
public static final int BLACK_COLOR
- See Also:
- Constant Field Values
-
mLogicalID
private java.lang.String mLogicalID
The logical id of the job as identified in the dax.
-
mLogicalName
private java.lang.String mLogicalName
The logical name of the node as identified in the dax.
-
mDepth
private int mDepth
The depth of the node from the root or any arbitary node.
-
mColor
private int mColor
The color the node is colored.
-
mParents
private java.util.Set<GraphNode> mParents
The list of parents of the job/node in the abstract graph. Each element of the list is aGraphNode
object.
-
mChildren
private java.util.Set<GraphNode> mChildren
The list of children of the job/node in the abstract graph. Each element of the list is aGraphNode
object.
-
mContent
private GraphNodeContent mContent
The content associated with this node.
-
-
Constructor Detail
-
GraphNode
public GraphNode()
The default constructor.
-
GraphNode
public GraphNode(java.lang.String id)
The overloaded constructor.- Parameters:
id
- the id of the node in the graph.
-
GraphNode
public GraphNode(java.lang.String id, GraphNodeContent content)
The overloaded constructor.- Parameters:
id
- the id of the node in the graph.content
- the content to be associated with the node.
-
GraphNode
public GraphNode(java.lang.String id, java.lang.String name)
The overloaded constructor.- Parameters:
id
- the logical id of the node.name
- the name of the node.
-
-
Method Detail
-
setBag
public void setBag(Bag bag)
Sets the bag of objects associated with the node. Overwrite the previous bag if existing.- Parameters:
bag
- theBag
to be associated with the node.
-
setContent
public void setContent(GraphNodeContent content)
Sets the content associated with the node. Overwrites the previous content if existing.- Parameters:
content
- theGraphNodeContent
to be associated with the node.
-
setParents
public void setParents(java.util.Collection<GraphNode> parents)
It adds the parents to the node. It ends up overwriting all the existing parents if some already exist.- Parameters:
parents
-
-
setChildren
public void setChildren(java.util.Collection<GraphNode> children)
It sets the children to the node. It ends up overwriting all the existing parents if some already exist.- Parameters:
children
-
-
setDepth
public void setDepth(int depth)
Sets the depth associated with the node.- Parameters:
depth
-
-
getBag
public Bag getBag()
Returns the bag of objects associated with the node.- Returns:
- the bag or null if no bag associated
-
getContent
public GraphNodeContent getContent()
Returns the content associated with the node.- Returns:
- the content or null if no content associated
-
getParents
public java.util.Collection<GraphNode> getParents()
Returns a list ofGraphNode
objects that are parents of the node.- Returns:
- list of
GraphNode
objects.
-
getChildren
public java.util.Collection<GraphNode> getChildren()
Returns a list ofGraphNode
objects that are children of the node.- Returns:
- list of
GraphNode
objects.
-
addChild
public void addChild(GraphNode child)
Adds a child to end of the child list.- Parameters:
child
- adds a child to the node.
-
addParent
public void addParent(GraphNode parent)
Adds a parent to end of the parent list.- Parameters:
parent
- adds a parent to the node.
-
removeChild
public void removeChild(GraphNode child)
Removes a child linkage to the node.- Parameters:
child
- child to be removed.
-
removeParent
public void removeParent(GraphNode parent)
Removes a parent linkage to the node.- Parameters:
parent
- parent to be removed.
-
resetEdges
public final void resetEdges()
Reset all the edges associated with this node.
-
getID
public java.lang.String getID()
Returns the logical id of the graph node.
-
getName
public java.lang.String getName()
Returns the logical name of the graph node.
-
getDepth
public int getDepth()
Returns the depth of the node in the graph.
-
isColor
public boolean isColor(int color)
Returns if the color of the node is as specified.- Parameters:
color
- color that node should be.
-
setColor
public void setColor(int color)
Sets the color of the node to the color specified- Parameters:
color
- color that node should be.
-
parentsColored
public boolean parentsColored(int color)
Returns if all the parents of that node have the color that is specified.- Parameters:
color
- the color of the node.- Returns:
- true if there are no parents or all parents are of the color. false in all other cases.
-
childrenColored
public boolean childrenColored(int color)
Returns if all the children of the node have the color that is specified.- Parameters:
color
- the color of the node.- Returns:
- true if there are no children or all children are of the color. false in all other cases.
-
parentsToString
public java.lang.String parentsToString()
A convenience methods that generates a comma separated list of parents as String- Returns:
- String
-
childrenToString
public java.lang.String childrenToString()
A convenience methods that generates a comma separated list of children as String- Returns:
- String
-
toString
public java.lang.String toString()
The textual representation of the graph node.
-
equals
public boolean equals(java.lang.Object obj)
Matches two GraphNode objects. A GraphNode object is considered equal to another if there id's match.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the reference object with which to compare.- Returns:
- true, if the primary keys match, false otherwise.
-
hashCode
public int hashCode()
Calculate a hash code value for the object to support hash based Collections.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for the object.
-
clone
public java.lang.Object clone()
Returns a copy of the object.- Overrides:
clone
in classjava.lang.Object
-
-