JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.javaGenes.graph
Class Edge

java.lang.Object
  extended bygov.nasa.alsUtility.Mark
      extended bygov.nasa.javaGenes.graph.GraphElement
          extended bygov.nasa.javaGenes.graph.Edge
All Implemented Interfaces:
java.lang.Cloneable, Compatible, java.io.Serializable
Direct Known Subclasses:
Bond, DirectedEdge

public class Edge
extends GraphElement
implements Compatible

Edges in Graphs. An edge connects two vertices.

See Also:
Graph, Vertex, Serialized Form

Field Summary
protected  Vertex[] vertices
          the vertices this edge connects
 
Constructor Summary
Edge()
           
 
Method Summary
 boolean canAcceptVerticesOf(Edge e)
           
 java.lang.Object clone()
           
 Vertex commonVertex(Edge edge)
           
 boolean dissimilarEdgeCompatibleWithVertices(Edge e)
           
 boolean doesConnect(Vertex v)
           
 java.lang.String getTypeString()
           
 Vertex getVertex(int which)
           
 boolean isCompatible(Compatible c)
           
 boolean isLegal()
           
 boolean isSame(Edge e)
           
 void makeCompatibleWithVertices()
          Force this edge to be compatible with its vertices.
 Vertex otherVertex(Vertex v)
           
 void removeVertices()
          sets the vertices to null
 void replaceVertex(Vertex oldVertex, Vertex newVertex)
          replace oldVertex with newVertex
 void setVertices(Vertex v1, Vertex v2)
          removes existing vertices removes "this" from edge list of existing vertices sets the vertices forces itself to be compatible (subclass responsibility)
 Edge shallowCopyEdge()
           
 void stealVertices(Edge e)
           
 java.lang.String toString()
           
 
Methods inherited from class gov.nasa.alsUtility.Mark
getMark, isMarked, setMark
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertices

protected Vertex[] vertices
the vertices this edge connects

Constructor Detail

Edge

public Edge()
Method Detail

shallowCopyEdge

public Edge shallowCopyEdge()
Returns:
connects the same vertices

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns:
connects the same vertices
Throws:
java.lang.CloneNotSupportedException

setVertices

public void setVertices(Vertex v1,
                        Vertex v2)
removes existing vertices removes "this" from edge list of existing vertices sets the vertices forces itself to be compatible (subclass responsibility)


makeCompatibleWithVertices

public void makeCompatibleWithVertices()
Force this edge to be compatible with its vertices. If any change is actually made, tell the vertices that their state has changed (they now have different edges). This is a noop here. It is used in some subclasses (e.g., chemical bonds [Bond]).


removeVertices

public void removeVertices()
sets the vertices to null


stealVertices

public void stealVertices(Edge e)
Parameters:
e - will lose its vertices! Be careful using it after this call.

replaceVertex

public void replaceVertex(Vertex oldVertex,
                          Vertex newVertex)
replace oldVertex with newVertex


otherVertex

public Vertex otherVertex(Vertex v)
Parameters:
v - one of the vertices this edge connects
Returns:
the other vertex

commonVertex

public Vertex commonVertex(Edge edge)
Returns:
the common vertex between this and parameter edge, null if none

getTypeString

public java.lang.String getTypeString()

toString

public java.lang.String toString()

getVertex

public Vertex getVertex(int which)

isCompatible

public boolean isCompatible(Compatible c)
Specified by:
isCompatible in interface Compatible
Returns:
true if argument is same class

isSame

public boolean isSame(Edge e)

dissimilarEdgeCompatibleWithVertices

public boolean dissimilarEdgeCompatibleWithVertices(Edge e)

canAcceptVerticesOf

public boolean canAcceptVerticesOf(Edge e)

doesConnect

public boolean doesConnect(Vertex v)
Returns:
true if this edge connects to parameter v

isLegal

public boolean isLegal()

JavaGenes, NASA Ames. Written largely by Al Globus