edu.mit.sketch.ddg
Class ConstraintGraph

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--edu.mit.sketch.ddg.ConstraintGraph
All Implemented Interfaces:
Cloneable, Map, Serializable

public class ConstraintGraph
extends Hashtable

A hashtable that stores the graph for a constraint of a particular type (like "connects"). If a constraint holds between to primitives (nodes in the graph), there will be an edge (ConstraintGraphEdge) between them. The edge also stores the confidence that the constraint holds and the importance of the constraint. The keys of the Hashtable are Primitives and the values are a list of outgoing directed edges (ConstraintGraphEdgeList).

Note: If the constraint is just a property of one primitive, it will have a self loop in the constraint graph.
If a primitive does not participate in the constraint at all, it will not be in the hashtable.

ConstraintGraph.java Created: Mon Feb 11 10:40:00 2002

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
ConstraintGraph()
           
 
Method Summary
 void addEdge(Primitive p1, ConstraintGraphEdge edge)
          Add an outgoing edge from a given primitive
 void addEdge(Primitive p1, Primitive p2, double confidence, double relevance)
          Add an edge between two given primitives.
 double confidence(Primitive p1, Primitive p2)
          Return the confidence of the constraint Returns 0 if the edge is not present.
 boolean containsEdge(Primitive p1, Primitive p2)
          Returns true if the graph contains an edge between the given primitives.
 Vector edgeList()
          Return the list primitive pairs for which this constraint holds.
 ConstraintGraphEdge getEdge(Primitive p1, Primitive p2)
          Get edge between the two given primitives.
 ConstraintGraphEdgeList getIncomingEdges(Primitive p2)
          Get the list of incoming edges for a given primitive.
 ConstraintGraphEdgeList getOutgoingEdges(Primitive p1)
          Get the list of outgoing edges for a given primitive.
 void print()
          Print the constraint graph
 double relevance(Primitive p1, Primitive p2)
          Return the relevance of the constraint Returns 0 if the edge is not present.
 ConstraintGraphEdge removeEdge(Primitive p1, Primitive p2)
          Remove and edge between two given primitives and return it.
 void setConfidence(Primitive p1, Primitive p2, double confidence)
          Change the confidence of the constraint
 void setRelevance(Primitive p1, Primitive p2, double relevance)
          Change the relevance of the constraint
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstraintGraph

public ConstraintGraph()
Method Detail

getOutgoingEdges

public ConstraintGraphEdgeList getOutgoingEdges(Primitive p1)
Get the list of outgoing edges for a given primitive. Returns null if the primitive is not in the graph.

getIncomingEdges

public ConstraintGraphEdgeList getIncomingEdges(Primitive p2)
Get the list of incoming edges for a given primitive. Returns null if the primitive is not in the graph.

addEdge

public void addEdge(Primitive p1,
                    Primitive p2,
                    double confidence,
                    double relevance)
Add an edge between two given primitives.

addEdge

public void addEdge(Primitive p1,
                    ConstraintGraphEdge edge)
Add an outgoing edge from a given primitive

getEdge

public ConstraintGraphEdge getEdge(Primitive p1,
                                   Primitive p2)
Get edge between the two given primitives. Returns null if the edge was not found.

removeEdge

public ConstraintGraphEdge removeEdge(Primitive p1,
                                      Primitive p2)
Remove and edge between two given primitives and return it. Returns null if the edge is not found.

containsEdge

public boolean containsEdge(Primitive p1,
                            Primitive p2)
Returns true if the graph contains an edge between the given primitives.

print

public void print()
Print the constraint graph

relevance

public double relevance(Primitive p1,
                        Primitive p2)
Return the relevance of the constraint Returns 0 if the edge is not present.

confidence

public double confidence(Primitive p1,
                         Primitive p2)
Return the confidence of the constraint Returns 0 if the edge is not present.

setRelevance

public void setRelevance(Primitive p1,
                         Primitive p2,
                         double relevance)
Change the relevance of the constraint

setConfidence

public void setConfidence(Primitive p1,
                          Primitive p2,
                          double confidence)
Change the confidence of the constraint

edgeList

public Vector edgeList()
Return the list primitive pairs for which this constraint holds. Each even element in the list is the first primitive in the pair and each odd element is the second primitive