edu.byu.ece.edif.util.graph
Class EdifCellInstanceCollectionGraph

java.lang.Object
  extended by edu.byu.ece.graph.AbstractGraph
      extended by edu.byu.ece.graph.BasicGraph
          extended by edu.byu.ece.edif.util.graph.AbstractEdifGraph
              extended by edu.byu.ece.edif.util.graph.EdifCellInstanceCollectionGraph
All Implemented Interfaces:
DirectedGraph, HierarchicalGraph, java.io.Serializable, java.lang.Cloneable

public class EdifCellInstanceCollectionGraph
extends AbstractEdifGraph
implements HierarchicalGraph

A graph view of an EdifCell object in which the graph nodes are collections of instances (EdifCellInstanceCollection objects). This class requires an instance of the EdifCellInstanceGraph during construction. This connectivity information is used to determine the edge relationships between grouped nodes.

TODO: I think this class should be named "EdifCellGroupConnectivity". The use of "instance" is confusing later on as I can't distinguish it from the EdifCellInstanceGraph.

See Also:
Serialized Form

Field Summary
protected  EdifCell _cell
           
protected  EdifCellInstanceGraph _ecic
           
protected  EdifCellInstanceGroupings _groupings
           
protected  java.util.Collection _topLevelPortNodes
          A Collection to keep track of the Top Level Port Nodes in this graph
static boolean DEBUG
           
 
Fields inherited from class edu.byu.ece.graph.BasicGraph
_nodes, _nodeSinkMap, _nodeSourceMap
 
Constructor Summary
  EdifCellInstanceCollectionGraph(EdifCell cell, EdifCellInstanceGroupings groupings, boolean includeTopLevelPorts)
           
protected EdifCellInstanceCollectionGraph(EdifCellInstanceCollectionGraph groupConn)
           
  EdifCellInstanceCollectionGraph(EdifCellInstanceGraph ecic, EdifCellInstanceGroupings groupings)
          Default to include Top Level Ports in the graph.
  EdifCellInstanceCollectionGraph(EdifCellInstanceGraph ecic, EdifCellInstanceGroupings groupings, boolean includeTopLevelPorts)
           
 
Method Summary
protected static EdifCellInstanceCollectionLink _addEdgeToCollectionLinksMap(EdifCellInstanceEdge edge, java.lang.Object sourceGroup, java.lang.Object sinkGroup, java.util.Map nodesToCollectionLink, EdifCellInstanceGroupings groupings)
          A double-mapping to keep track of CollectionLink objects based on their source and sink groups.
protected  void _init(EdifCellInstanceGraph ecic, boolean includeTopLevelPorts)
          Initializes the connectivity maps for the given cell.
protected  void _mergeEdges(EdifCellInstanceCollection group, java.util.Collection newConnectedNodes, boolean checkSourceEdges)
          Examines the input or output Edges (depending on checkSourceEdges) for CollectionLink Edges that should be merged.
protected  void _mergeEdgesNoCheck(java.util.Collection edges, java.lang.Object source, java.lang.Object sink)
          Merges the given Collection of EdifCellInstanceCollectionLink objects into one.
 java.lang.Object clone()
          Clone the BasicGraph object.
 boolean containsInnerNode(java.lang.Object node)
           
 EdifCell getCell()
          Provide the EdifCell object that this graph is based on.
 EdifCellInstanceGroupings getGroupings()
           
 java.util.Collection<EdifCellInstanceEdge> getInnerEdges(Edge edge)
           
 EdifCellInstanceGraph getInnerGraph()
           
 java.util.Collection getInnerNodes(java.lang.Object node)
           
 EdifCellInstanceGraph getNodeGraph(java.lang.Object node)
           
 java.lang.Object getParentNode(java.lang.Object node)
           
 BasicGraph getSubGraph(java.util.Collection eciColls)
          Creates an EdifCellInstanceCollectionGraph object that contains only the information linking the given Collection of EdifCellInstanceCollection objects.
 java.util.Collection getTopLevelPortNodes()
           
 boolean isNodeTopLevelPort(java.lang.Object node)
           
 EdifCellInstanceCollection mergeGroupIntoGroup(EdifCellInstanceCollection group1, EdifCellInstanceCollection group2)
          Merges the two passed-in groups by adding the contents of group1 into group2.
 void removeNode(java.lang.Object node, boolean removeAllEdges)
          Removes the given node Object from the graph
 
Methods inherited from class edu.byu.ece.graph.BasicGraph
addEdge, addNode, addNodes, containsNode, getEdge, getEdges, getEdges, getInputEdges, getNodes, getNodesWithNoInputEdges, getNodesWithNoOutputEdges, getOutputEdges, getSinkNodes, getSourceNodes, getSubGraph2, invert, removeEdge, removeEdges, removeNode, topologicalSort
 
Methods inherited from class edu.byu.ece.graph.AbstractGraph
_getAncestorsOrDescendents, _getAncestorsOrDescendents, getAncestors, getAncestors, getDescendents, getDescendents, getPredecessors, getSuccessors, toDotty, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.byu.ece.graph.DirectedGraph
containsNode, getAncestors, getDescendents, getEdge, getEdges, getInputEdges, getNodes, getOutputEdges, getPredecessors, getSuccessors, invert
 

Field Detail

_cell

protected EdifCell _cell

_ecic

protected EdifCellInstanceGraph _ecic

_groupings

protected EdifCellInstanceGroupings _groupings

_topLevelPortNodes

protected java.util.Collection _topLevelPortNodes
A Collection to keep track of the Top Level Port Nodes in this graph


DEBUG

public static boolean DEBUG
Constructor Detail

EdifCellInstanceCollectionGraph

public EdifCellInstanceCollectionGraph(EdifCell cell,
                                       EdifCellInstanceGroupings groupings,
                                       boolean includeTopLevelPorts)

EdifCellInstanceCollectionGraph

public EdifCellInstanceCollectionGraph(EdifCellInstanceGraph ecic,
                                       EdifCellInstanceGroupings groupings)
Default to include Top Level Ports in the graph.


EdifCellInstanceCollectionGraph

public EdifCellInstanceCollectionGraph(EdifCellInstanceGraph ecic,
                                       EdifCellInstanceGroupings groupings,
                                       boolean includeTopLevelPorts)

EdifCellInstanceCollectionGraph

protected EdifCellInstanceCollectionGraph(EdifCellInstanceCollectionGraph groupConn)
Method Detail

clone

public java.lang.Object clone()
Description copied from class: BasicGraph
Clone the BasicGraph object.

Overrides:
clone in class BasicGraph

containsInnerNode

public boolean containsInnerNode(java.lang.Object node)
Specified by:
containsInnerNode in interface HierarchicalGraph
Parameters:
node - A node to look for in the inner graph
Returns:
true if the given node is found in the inner graph

getCell

public EdifCell getCell()
Description copied from class: AbstractEdifGraph
Provide the EdifCell object that this graph is based on.

Specified by:
getCell in class AbstractEdifGraph
Returns:
EdifCell object used to create this graph.

removeNode

public void removeNode(java.lang.Object node,
                       boolean removeAllEdges)
Removes the given node Object from the graph

Overrides:
removeNode in class BasicGraph
Parameters:
edge - The node Object to remove
removeAllEdges - If true, removes ALL Edges that refer to this node, not just the ones mapped from this node (the easy-to-get-to Edges). In other words, true removes ALL references to this node, while false may leave some Edges that refer to this node.

getTopLevelPortNodes

public java.util.Collection getTopLevelPortNodes()

isNodeTopLevelPort

public boolean isNodeTopLevelPort(java.lang.Object node)

getGroupings

public EdifCellInstanceGroupings getGroupings()

getInnerEdges

public java.util.Collection<EdifCellInstanceEdge> getInnerEdges(Edge edge)
Specified by:
getInnerEdges in interface HierarchicalGraph
Parameters:
edge - An Edge object in thie HierarchicalGraph
Returns:
A Collection of Edge objects corresponding to the given edge's inner edges (those that make up this edge)

getInnerGraph

public EdifCellInstanceGraph getInnerGraph()
Specified by:
getInnerGraph in interface HierarchicalGraph
Returns:
The inside graph that this graph is built upon

getInnerNodes

public java.util.Collection getInnerNodes(java.lang.Object node)
Specified by:
getInnerNodes in interface HierarchicalGraph
Parameters:
node - A node in this HierarchicalGraph
Returns:
A Collection of nodes from the inner graph that correspond to the given node in this graph

getNodeGraph

public EdifCellInstanceGraph getNodeGraph(java.lang.Object node)
Specified by:
getNodeGraph in interface HierarchicalGraph
Parameters:
node - A node in this HierarchicalGraph
Returns:
A DirectedGraph object which is the subgraph corresponding to the given node's inner nodes or null if the node passed in isn't of the correct type

getParentNode

public java.lang.Object getParentNode(java.lang.Object node)
Specified by:
getParentNode in interface HierarchicalGraph
Parameters:
node - A node in the inner graph
Returns:
The node in this HierarchicalGraph that corresponds to the given inner node or null if not found.

getSubGraph

public BasicGraph getSubGraph(java.util.Collection eciColls)
Creates an EdifCellInstanceCollectionGraph object that contains only the information linking the given Collection of EdifCellInstanceCollection objects.

Specified by:
getSubGraph in interface DirectedGraph
Overrides:
getSubGraph in class BasicGraph
Parameters:
ecics - The Collection of EdifCellInstanceCollection objects of interest
Returns:
A new EdifCellInstanceCollectionGraph object containing only the given ecics

mergeGroupIntoGroup

public EdifCellInstanceCollection mergeGroupIntoGroup(EdifCellInstanceCollection group1,
                                                      EdifCellInstanceCollection group2)
Merges the two passed-in groups by adding the contents of group1 into group2. group1 is deleted and group2 remains.

Parameters:
group1 - The group to remove
group2 - The group to add to
Returns:
A reference to the expanded group (group2)

_init

protected void _init(EdifCellInstanceGraph ecic,
                     boolean includeTopLevelPorts)
Initializes the connectivity maps for the given cell. Note that this happens only once and that this does not track changes in the EdifCell. If the cell changes, this connectivity will be stale.


_addEdgeToCollectionLinksMap

protected static EdifCellInstanceCollectionLink _addEdgeToCollectionLinksMap(EdifCellInstanceEdge edge,
                                                                             java.lang.Object sourceGroup,
                                                                             java.lang.Object sinkGroup,
                                                                             java.util.Map nodesToCollectionLink,
                                                                             EdifCellInstanceGroupings groupings)
A double-mapping to keep track of CollectionLink objects based on their source and sink groups. The mapping is: source group -> map2, map2: sink group -> CollectionLink

Parameters:
edge - The EdifCellInstanceEdge to add
nodesToCollectionLink - The double Map
groupings - The associated EdifCellInstanceGroupings object
Returns:
The EdifCellInstanceCollectionLink object that this edge was added to.

_mergeEdges

protected void _mergeEdges(EdifCellInstanceCollection group,
                           java.util.Collection newConnectedNodes,
                           boolean checkSourceEdges)
Examines the input or output Edges (depending on checkSourceEdges) for CollectionLink Edges that should be merged. Only checks for duplicate Edges with the given new nodes as predecessor/successor nodes.


_mergeEdgesNoCheck

protected void _mergeEdgesNoCheck(java.util.Collection edges,
                                  java.lang.Object source,
                                  java.lang.Object sink)
Merges the given Collection of EdifCellInstanceCollectionLink objects into one. WARNING: This method assumes that the Edges have the same source and sink. It will not check this assumption.