|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmocgraph.Graph
mocgraph.DirectedGraph
mapss.dif.DIFGraph
public class DIFGraph
Information associated with an DIF graph. This class caches frequently-used data associated with DIF graphs. It is also useful for intermediate DIF graph representations that do not correspond to Ptolemy II models, and performing graph transformations (e.g. conversion to and manipulation of single-rate graphs). It is intended for use with analysis/synthesis algorithms that operate on generic graph representations of CSDF models.
The attribute mechanism in this class can be used to bind arbitrary attributes
to elements (mocgraph.Node and mocgraph.Edge) or the graph itself.
Implementation details of this mechanism can be
found in AttributeContainer
and
DIFAttribute
.
DIF supports parameterizing values as parameters. The parameter mechanism of
DIFGraph handles this task. Implementation details can be found in
DIFParameter
.
Containers for AttributeContainer and containers for DIFParameter are implemented as LinkedHashMap. The "HashMap" property provides a good way to retrive contents and the "linked" property maintains the order of insertion.
DIFEdgeWeight
,
DIFNodeWeight
,
AttributeContainer
,
DIFAttribute
,
DIFParameter
Constructor Summary | |
---|---|
DIFGraph()
Construct an empty DIF graph. |
|
DIFGraph(int nodeCount)
Construct an empty DIF graph with enough storage allocated for the specified number of nodes. |
|
DIFGraph(int nodeCount,
int edgeCount)
Construct an empty DIF graph with enough storage allocated for the specified number of edges, and number of nodes. |
Method Summary | |
---|---|
protected AttributeContainer |
_getAttributeContainer(java.lang.Object object)
Returns a container in which attributes of an edge, a node or the graph are stored. |
protected void |
_registerEdge(mocgraph.Edge edge)
Register a new edge in the graph. |
protected void |
_registerNode(mocgraph.Node node)
Register a new node in the graph. |
protected AttributeContainer |
_removeAttributeContainer(java.lang.Object object)
Remove the AttributeContainer of graph itself or graph element. |
protected java.util.LinkedList |
_removeReferenceFromAttributes(java.lang.Object refObj)
If any attribute in graph or elements of graph contains refObj as value, remove that element object from the attribute. |
protected AttributeContainer |
_setAttributeContainer(java.lang.Object object,
AttributeContainer container)
Sets a container for this object in which attributes of an edge, a node or the graph can be stored. |
mocgraph.Edge |
addEdge(mocgraph.Node node1,
mocgraph.Node node2)
This operation is unsupported and always throws a GraphWeightException. |
java.util.Collection |
addEdge(java.lang.Object weight1,
java.lang.Object weight2)
This operation is unsupported and always throws a GraphWeightException. |
boolean |
equals(java.lang.Object graph)
Test if a graph is equal to this one. |
DIFAttribute |
getAttribute(mocgraph.Element element,
java.lang.String name)
Returns the DIFAttribute associated with the element. |
DIFAttribute |
getAttribute(java.lang.String name)
Returns the DIFAttribute associated with this graph. |
DIFAttribute |
getAttributeByContent(mocgraph.Element element,
java.lang.Object value)
Returns the first DIFAttribute of the element that contains the given value. |
DIFAttribute |
getAttributeByContent(java.lang.Object value)
Returns the first DIFAttribute of this graph that contains the given value object. |
java.lang.String |
getAttributeDescriptions()
Returns the description of the graph attributes as defined in getAttributeDescriptions(Element) . |
java.lang.String |
getAttributeDescriptions(mocgraph.Element element)
Returns the description of a graph element (node/edge) with its attributes.This description contains the name of the object as defined by setName(java.lang.String) method, names and values of the attributes. |
java.util.LinkedList |
getAttributeNames()
Returns a list of attribute names that can be found associated with this graph. |
java.util.LinkedList |
getAttributeNames(mocgraph.Element element)
Returns a list of attribute names that can be found associated with this element. |
java.util.LinkedList |
getAttributes()
Returns a LinkedList of DIFAttribute associated with this graph. |
java.util.LinkedList |
getAttributes(mocgraph.Element element)
Returns a LinkedList of DIFAttribute associated with this element. |
java.util.LinkedList |
getAttributesByContent(mocgraph.Element element,
java.lang.Object value)
Returns the DIFAttributes of the element that contain the given value object. |
java.util.LinkedList |
getAttributesByContent(java.lang.Object value)
Returns the DIFAttributes in this graph that contain the given value object. |
mocgraph.Edge |
getEdge(java.lang.String name)
Returns the edge by name. |
java.lang.String |
getName()
Returns the name of this graph which is assigned by the setName(java.lang.String) method. |
java.lang.String |
getName(mocgraph.Element element)
Returns the name of this edge/node which is assigned by the setName(java.lang.String) method. |
mocgraph.Node |
getNode(java.lang.String name)
Returns the node by name. |
java.lang.Object |
getObject(java.lang.String name)
Returns the first object that has this name specified by getName method. |
DIFParameter |
getParameter(java.lang.String name)
Returns the DIFParameter with the given name. |
java.util.LinkedList |
getParameterNames()
Returns all the parameter names based on the order of insertion. |
java.util.LinkedList |
getParameters()
Returns all DIFParameter s. |
int |
hashCode()
Returns the hash code for this graph. |
boolean |
hideEdge(mocgraph.Edge edge)
Hide an edge in this graph. |
boolean |
mergeGraph(mocgraph.Graph graph)
Merge graph into this graph. |
DIFGraph |
mirror()
Mirror this graph. |
DIFGraph |
mirror(java.util.Map mirrorMap)
Mirror this graph. |
void |
removeAllAttributes()
Remove all DIFAttribute from the AttributeContainer associated with this graph. |
void |
removeAllAttributes(mocgraph.Element element)
Remove all DIFAttribute from the AttributeContainer associated with this element. |
DIFAttribute |
removeAttribute(DIFAttribute attribute)
Removes the DIFAttribute from the attribute container of the graph. |
DIFAttribute |
removeAttribute(mocgraph.Element element,
DIFAttribute attribute)
Removes the DIFAttribute from the attribute container of the element. |
DIFAttribute |
removeAttribute(mocgraph.Element element,
java.lang.String name)
Removes the DIFAttribute with the given name from the attribute container of this element. |
DIFAttribute |
removeAttribute(java.lang.String name)
Removes the DIFAttribute with the given name from the attribute container of the graph. |
boolean |
removeEdge(mocgraph.Edge edge)
Remove an edge from this graph. |
boolean |
removeNode(mocgraph.Node node)
Remove a node from this graph. |
DIFParameter |
removeParameter(java.lang.String name)
Removes the parameter defined by the given name from the parameter list. |
boolean |
restoreEdge(mocgraph.Edge edge)
Restore an edge in this graph. |
void |
setAttribute(DIFAttribute attribute)
Sets an attribute of the graph. |
void |
setAttribute(mocgraph.Element element,
DIFAttribute attribute)
Sets an attribute of an element. |
java.lang.String |
setName(mocgraph.Element element,
java.lang.String name)
Sets the name of this edge/node. |
java.lang.String |
setName(java.lang.String name)
Sets the name of this graph. |
DIFParameter |
setParameter(DIFParameter parameter)
Add a DIFParameter to the graph. |
mocgraph.Graph |
subgraph(java.util.Collection nodes)
Overrides the method in mocgraph.Graph to copy the
attributes as well. |
mocgraph.Graph |
subgraph(java.util.Collection nodeCollection,
java.util.Collection edgeCollection)
Overrides the method in mocgraph.Graph to copy the
attributes as well. |
boolean |
validEdgeWeight(java.lang.Object object)
Returns true if the given object is a valid edge weight for this graph. |
boolean |
validNodeWeight(java.lang.Object object)
Returns true if the given object is a valid node weight for this graph. |
Methods inherited from class mocgraph.DirectedGraph |
---|
_connect, _connectedSubGraph, _disconnect, _initializeAnalyses, backwardReachableNodes, backwardReachableNodes, backwardReachableNodes, backwardReachableNodes, cycleNodeCollection, cycleNodes, edgeExists, edgeExists, inputEdgeCount, inputEdges, isAcyclic, outputEdgeCount, outputEdges, predecessorEdges, predecessors, reachableNodes, reachableNodes, reachableNodes, reachableNodes, sccDecomposition, selfLoopEdgeCount, sinkNodeCount, sinkNodes, sourceNodeCount, sourceNodes, subgraphs, successorEdges, successors, toDirectedAcyclicGraph, topologicalSort, topologicalSort, transitiveClosure |
Methods inherited from class mocgraph.Graph |
---|
_addEdge, _connectEdge, _disconnectEdge, _emptyGraph, _registerChange, addAnalysis, addEdge, addEdge, addEdge, addEdges, addGraph, addNode, addNode, addNodes, addNodeWeight, addNodeWeights, changeCount, clone, cloneAs, connectedComponents, containsEdge, containsEdgeWeight, containsNode, containsNodeWeight, edge, edge, edgeCount, edgeLabel, edgeLabel, edges, edges, edges, edgeWeight, hidden, hiddenEdgeCount, hiddenEdges, incidentEdgeCount, incidentEdges, neighborEdges, neighbors, node, node, nodeCount, nodeLabel, nodeLabel, nodes, nodes, nodes, nodeWeight, selfLoopEdgeCount, selfLoopEdges, selfLoopEdges, toString, validateWeight, validateWeight, validateWeight, validateWeight, weightArray |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DIFGraph()
n +
label for nodes
and e +
label for edges.
public DIFGraph(int nodeCount)
n +
label for nodes
and e +
label for edges.
nodeCount
- The number of nodes.public DIFGraph(int nodeCount, int edgeCount)
n +
label for nodes and
e +
label for edges.
nodeCount
- The integer specifying the number of nodesedgeCount
- The integer specifying the number of edgesMethod Detail |
---|
public java.util.Collection addEdge(java.lang.Object weight1, java.lang.Object weight2)
addEdge
in class mocgraph.Graph
mocgraph.GraphWeightException
- Always thrown.public mocgraph.Edge addEdge(mocgraph.Node node1, mocgraph.Node node2)
addEdge
in class mocgraph.Graph
mocgraph.GraphWeightException
- Always thrown.public boolean equals(java.lang.Object graph)
equals
in class mocgraph.Graph
graph
- The graph with which to compare this graph.
public DIFAttribute getAttribute(java.lang.String name)
name
- The name of this DIFAttribute.
DIFAttribute
,
AttributeContainer
public DIFAttribute getAttribute(mocgraph.Element element, java.lang.String name)
element
- An edge or node in this graph.name
- The name of this DIFAttribute.
use #getAttribute(String, String)
.
mocgraph.GraphElementException
- If the element is not contained in
the graph.DIFAttribute
,
AttributeContainer
public java.util.LinkedList getAttributes()
AttributeContainer
public java.util.LinkedList getAttributes(mocgraph.Element element)
element
- An edge or node in this graph.
AttributeContainer
public DIFAttribute getAttributeByContent(java.lang.Object value)
value
- The value object (token or object reference) contained
by this DIFAttribute.
public java.util.LinkedList getAttributesByContent(java.lang.Object value)
value
- The value object.
public DIFAttribute getAttributeByContent(mocgraph.Element element, java.lang.Object value)
element
- An edge or node in this graph.value
- The value object (token or object reference) contained
by this DIFAttribute.
public java.util.LinkedList getAttributesByContent(mocgraph.Element element, java.lang.Object value)
value
- The value object.
public java.lang.String getAttributeDescriptions()
getAttributeDescriptions(Element)
.
public java.lang.String getAttributeDescriptions(mocgraph.Element element)
setName(java.lang.String)
method, names and values of the attributes.
element
- An edge or node in this graph.
mocgraph.GraphElementException
- If the element is not contained in
the graph.public java.util.LinkedList getAttributeNames()
public java.util.LinkedList getAttributeNames(mocgraph.Element element)
element
- An edge or node in this graph.
mocgraph.GraphElementException
- If the element is not contained in
the graph.public mocgraph.Edge getEdge(java.lang.String name)
name
- A name string.
public java.lang.String getName()
setName(java.lang.String)
method. If no name or null was assigned as the name
it is set to empty string.
public java.lang.String getName(mocgraph.Element element)
setName(java.lang.String)
method. If no name or null was assigned as the
name it is set to empty string.
element
- An edge or node in this graph.
mocgraph.GraphElementException
- If the element is not contained in
the graph.public mocgraph.Node getNode(java.lang.String name)
name
- A name string.
public java.lang.Object getObject(java.lang.String name)
name
- A string.
public DIFParameter getParameter(java.lang.String name)
name
- The name of the parameter.
public java.util.LinkedList getParameterNames()
public java.util.LinkedList getParameters()
DIFParameter
s.
public int hashCode()
hashCode
in class mocgraph.Graph
public boolean hideEdge(mocgraph.Edge edge)
hideEdge
in class mocgraph.Graph
edge
- The edge to be removed.
Graph.hideEdge(mocgraph.Edge)
public boolean mergeGraph(mocgraph.Graph graph)
Note that after performing this method, use of the original graph is not recommended since certain cross references are set to this graph.
graph
- The graph to add.
mocgraph.GraphConstructionException
- If a node or edge in the source
graph already exists in this graph.public DIFGraph mirror()
DIFHierarchy.mirror()
.
public DIFGraph mirror(java.util.Map mirrorMap)
DIFHierarchy.mirror()
.
mirrorMap
- external mappings of elements in hierarchy.
This method will also put mappings of graph elements, parameters,
attribute containers into mirrorMap.
public void removeAllAttributes()
public void removeAllAttributes(mocgraph.Element element)
element
- An edge or node in this graph.public DIFAttribute removeAttribute(DIFAttribute attribute)
attribute
- The DIFAttribute object.
AttributeContainer
public DIFAttribute removeAttribute(java.lang.String name)
name
- The name of the DIFAttribute to be deleted.
AttributeContainer
public DIFAttribute removeAttribute(mocgraph.Element element, DIFAttribute attribute)
element
- An edge or node in this graph.attribute
- The DIFAttribute object.
AttributeContainer
public DIFAttribute removeAttribute(mocgraph.Element element, java.lang.String name)
element
- An edge or node in this graph.name
- The name of the attribute to be deleted.
mocgraph.GraphElementException
- If the element is not contained in
the graph.AttributeContainer
public boolean restoreEdge(mocgraph.Edge edge)
restoreEdge
in class mocgraph.Graph
edge
- The edge to be removed.
Graph.hideEdge(mocgraph.Edge)
public boolean removeEdge(mocgraph.Edge edge)
Graph.addEdge(Edge)
),
provided that the incident nodes are still in the graph. However
previous attributes of the edge won't be recovered.
removeEdge
in class mocgraph.Graph
edge
- The edge to be removed.
public boolean removeNode(mocgraph.Node node)
removeNode
in class mocgraph.Graph
node
- The node to be removed.
public DIFParameter removeParameter(java.lang.String name)
name
- Name of the interval to be removed.
public void setAttribute(DIFAttribute attribute)
attribute
- A DIFAttribute.
java.lang.IllegalArgumentException
- If the name of attribute is null.public void setAttribute(mocgraph.Element element, DIFAttribute attribute)
element
- An edge or node in this graph.attribute
- A DIFAttribute.
mocgraph.GraphElementException
- If the element is not contained in
the graph.
java.lang.IllegalArgumentException
- If the name of attribute is null.public java.lang.String setName(java.lang.String name)
name
- Name string.
See {link mapss.dif.AttributeContainer#setName} for restrictions
imposed on the name.
java.lang.IllegalArgumentException
- If
Conventions.labelConvention(java.lang.String)
returns an error.public java.lang.String setName(mocgraph.Element element, java.lang.String name)
n +
label for nodes and
e +
label for edges.
element
- An edge or node in this graph.name
- Name string.
mocgraph.GraphElementException
- If the element is not contained in
the graph.
java.lang.IllegalArgumentException
- Conventions.labelConvention(java.lang.String)
returns an error.public DIFParameter setParameter(DIFParameter parameter)
parameter
- A DIFParameter with a name.
public mocgraph.Graph subgraph(java.util.Collection nodes)
mocgraph.Graph
to copy the
attributes as well. For each element copied, attributes will be copied
together. Special attention should be given that parameter values
are not copied therefore values of the parameterized attributes should
be copied from the original graph manually (if desired).
subgraph
in class mocgraph.Graph
nodes
- The collection of nodes; each element is a Node
.
public mocgraph.Graph subgraph(java.util.Collection nodeCollection, java.util.Collection edgeCollection)
mocgraph.Graph
to copy the
attributes as well. For each element copied, attributes will be copied
together. Special attention should be given that parameter values
are not copied therefore values of the parameterized attributes should
be copied from the original graph manually (if desired).
subgraph
in class mocgraph.Graph
nodeCollection
- The subset of nodes; each element is an instance
of Node
.edgeCollection
- The subset of edges. Each element is an instance
of Edge
.
public boolean validEdgeWeight(java.lang.Object object)
validEdgeWeight
in class mocgraph.Graph
public boolean validNodeWeight(java.lang.Object object)
validNodeWeight
in class mocgraph.Graph
protected AttributeContainer _getAttributeContainer(java.lang.Object object)
In setName method name of the returned container is used as the name of the edge/node or graph.
object
- A graph edge/node or the graph itself.
mocgraph.GraphElementException
- If the runtime class of this object
is an edge/node and it is not contained in the graph.protected void _registerEdge(mocgraph.Edge edge)
_registerEdge
in class mocgraph.Graph
edge
- The new edge.
java.lang.IllegalArgumentException
- If the edge is unweighted or
has a weight that is not an instance of DIFEdgeWeight
.protected void _registerNode(mocgraph.Node node)
_registerNode
in class mocgraph.DirectedGraph
node
- The new node.
java.lang.IllegalArgumentException
- If the node is unweighted or
has a weight that is not an instance of DIFNodeWeight
.protected java.util.LinkedList _removeReferenceFromAttributes(java.lang.Object refObj)
protected AttributeContainer _setAttributeContainer(java.lang.Object object, AttributeContainer container)
object
- A graph edge/node or the graph itself.container
- An AttributeContainer.
protected AttributeContainer _removeAttributeContainer(java.lang.Object object)
object
- A graph edge/node or the graph itself.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |